casacore
Loading...
Searching...
No Matches
Arrays.h
Go to the documentation of this file.
1// # Arrays.h: A module implementing multidimensional arrays and operations
2// # Copyright (C) 1995,1999,2000
3// # Associated Universities, Inc. Washington DC, USA.
4// #
5// # This library is free software; you can redistribute it and/or modify it
6// # under the terms of the GNU Library General Public License as published by
7// # the Free Software Foundation; either version 2 of the License, or (at your
8// # option) any later version.
9// #
10// # This library is distributed in the hope that it will be useful, but WITHOUT
11// # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12// # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13// # License for more details.
14// #
15// # You should have received a copy of the GNU Library General Public License
16// # along with this library; if not, write to the Free Software Foundation,
17// # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18// #
19// # Correspondence concerning AIPS++ should be addressed as follows:
20// # Internet email: casa-feedback@nrao.edu.
21// # Postal address: AIPS++ Project Office
22// # National Radio Astronomy Observatory
23// # 520 Edgemont Road
24// # Charlottesville, VA 22903-2475 USA
25
26#ifndef CASA_ARRAYS_H
27#define CASA_ARRAYS_H
28
29#include <casacore/casa/aips.h>
30
31#include <casacore/casa/Arrays/IPosition.h>
32#include <casacore/casa/Arrays/Slicer.h>
33#include <casacore/casa/Arrays/Slice.h>
34
35#include <casacore/casa/Arrays/Array.h>
36#include <casacore/casa/Arrays/Vector.h>
37#include <casacore/casa/Arrays/Matrix.h>
38#include <casacore/casa/Arrays/Cube.h>
39
40#include <casacore/casa/Arrays/ArrayIter.h>
41#include <casacore/casa/Arrays/MatrixIter.h>
42#include <casacore/casa/Arrays/VectorIter.h>
43
44#include <casacore/casa/Arrays/ArrayMath.h>
45#include <casacore/casa/Arrays/ArrayPartMath.h>
46#include <casacore/casa/Arrays/MatrixMath.h>
47#include <casacore/casa/Arrays/ArrayLogical.h>
48#include <casacore/casa/IO/ArrayIO.h>
49#include <casacore/casa/Arrays/ArrayError.h>
50
51#include <casacore/casa/Arrays/LogiArray.h>
52#include <casacore/casa/Arrays/LogiVector.h>
53#include <casacore/casa/Arrays/LogiMatrix.h>
54#include <casacore/casa/Arrays/LogiCube.h>
55
56#include <casacore/casa/Arrays/MaskedArray.h>
57#include <casacore/casa/Arrays/MaskArrMath.h>
58#include <casacore/casa/Arrays/MaskArrLogi.h>
59#include <casacore/casa/Arrays/MaskArrIO.h>
60#include <casacore/casa/Arrays/MaskLogiArr.h>
61
62namespace casacore { // # NAMESPACE CASACORE - BEGIN
63
64// <module>
65//
66// <summary>
67// A module implementing multidimensional arrays and operations.
68// </summary>
69
70// <reviewed reviewer="UNKNOWN" date="before2004/08/25" demos="">
71// </reviewed>
72
73// <etymology>
74// This module provides classes and global functions for multidimensional
75// arrays.
76// </etymology>
77//
78// <synopsis>
79// Arrays have traditionally played an important role in scientific
80// computation. While it is certainly true that some of the reliance on
81// arrays was due to the paucity of other data structures in FORTRAN, it
82// is also true that computation on arrays reflects the common occurrence
83// of regularly sampled multi-dimensioned data in science.
84//
85// The <linkto module=Lattices>Lattices</linkto> are a generalization
86// of Arrays. They can handle memory- and disk-based arrays as well
87// as other types of arrays (eg. expressions).
88//
89// The module consists of various parts:
90// <ul>
91
92// <li>
93// <linkto class=Array>Array</linkto> is the basic array class. It is
94// only templated on data type, not on dimensionality like the array
95// classes in Blitz and boost.
96// It has a non-templated base class ArrayBase.
97//
98// <linkto class=Vector>Vector</linkto>,
99// <linkto class=Matrix>Matrix</linkto>, and
100// <linkto class=Cube>Cube</linkto>
101// are the one, two, and three dimensional specializations respectively of
102// Array.
103//
104// <li>
105// <linkto class=MaskedArray>MaskedArray</linkto> is the class used to mask
106// an Array for operations on that Array.
107//
108// <li>
109// <linkto class=ArrayError>ArrayError</linkto> is the base class for all
110// Array exception classes.
111//
112// <li>
113// There are several ways o iterate through an array:
114// <ul>
115// <li> The STL-style Array iterators can be used to iterate
116// element by element through an array. This is the fastest way.
117// They also make it possible to virtually extend an array (called
118// shape broadcasting in numpy) and to reorder the iteration axes.
119// <li> <linkto class=ArrayIterator>ArrayIterator</linkto> can be used to
120// iterate line by line, plane by plane, etc. through an array.
121// Each subset is an array in itself, thus can be iterated again.
122// <li> The Array function operators () can be used to get a subset from
123// an array. They can be used for iteration, but that is slower than
124// the ways mentioned above.
125// <li> The array operator[] can be used to get the i-th subset. It can
126// be used for iteration, but ArrayIterator does the same and is faster.
127// <li> ArrayAccessor is useful when neighbours of an array element have
128// to be visited.
129// <li> <linkto class=LatticeIterator>LatticeIterator</linkto> can be used on
130// a <linkto class=ArrayLattice>ArrayLattice</linkto> object for more
131// advanced iteration. However, they are part of the lattices packages.
132// </ul>
133//
134// <li>
135// <linkto group="ArrayMath.h#Array mathematical operations">Mathematical</linkto>,
136// <linkto group="ArrayLogical.h#Array logical operations">logical</linkto>,
137// <linkto group="ArrayPartMath.h#Array partial operations">chunked mathematical and
138// logical</linkto>, <linkto group="ArrayIO.h#Array IO">IO</linkto>, and other useful operations are
139// provided for Arrays and MaskedArrays.
140//
141// ArrayMath also defines various STL-style transform functions that use the
142// Array iterators and functors like Plus to apply the mathematical and logical
143// operations. They can, however, also be used directly on arrays of
144// different types making it possible to, say, add a Complex and double array
145// with a DComplex result.
146// <br>It also has a <src>transformInPlace</src> to avoid needless incrementing
147// of iterators which have to be done when using <src>std::transform</src>
148// for in-place operations.
149//
150// <li>
151// Orthogonal n-space descriptors - useful when a shape of an Array is
152// needed or when a sub-region within an Array is required.
153// <ul>
154// <li> The <linkto class="IPosition">IPosition</linkto> class name is a
155// concatenation of "Integer Position." IPosition objects are normally
156// used to index into, and define the shapes of, Arrays and Lattices. For
157// example, if you have a 5-dimensional array, you need an IPosition of
158// length 5 to index into the array (or to define its shape, etc.). It is
159// essentially a vector of integers. The IPosition vector may point to
160// the "top right corner" of some shape, or it may be an indicator of a
161// specific position in n-space. The interpretation is context dependent.
162// The constructor consists of an initial argument which specifies the
163// number of axes, followed by the appropriate number of respective axis
164// lengths. Thus the constructor needs N+1 arguments for an IPosition
165// of length N. IPositions have the standard integer math relationships
166// defined. The dimensionality of the operator arguments must be the
167// same.
168//<srcblock>
169// // Make a shape with three axes, x = 24, y = 48, z = 16;
170// IPosition threeSpace(3, 24, 48, 16);
171//
172// // get the value of the ith axis (note: C++ is zero based!)
173// Int xShape = threeSpace(0);
174// Int zShape = threeSpace(2);
175//
176// // construct another with all three axes values equal to 666;
177// IPosition threeSpaceAlso(3,666);
178//
179// // do math with the IPositions...
180// threeSpace += threeSpaceAlso;
181// AlwaysAssert(threeSpace(1) == 714, AipsError);
182// </srcblock>
183//
184// <li> The <linkto class="Slicer">Slicer</linkto> class name may be
185// thought of as a short form of "n-Dimensional Slice Specifier."
186// This object is used to bundle into one place all the information
187// necessary to specify a regular subregion within an Array or Lattice.
188// In other words, Slicer holds the location of a "slice" of a
189// greater whole. Construction is with up to 3 IPositions: the start
190// location of the subspace within the greater space; the shape or end
191// location of the subspace within the greater space; and the stride,
192// or multiplier to be used for each axis. The stride gives the user
193// the chance to use every i-th piece of data, rather than every
194// position on the axis.
195// <br>
196// It is possible to leave some values in the given start or end/length
197// unspecified. Such unspecified values default to the boundaries of the
198// array to which the slicer will be applied.
199// It is also possible to use a non-zero origin when applying the slicer
200// to an array.
201//
202// <srcblock>
203// // Define the shape of an array.
204// IPosition shape(2,20,30);
205//
206// // Also define an origin.
207// IPosition origin(2,-5,15);
208//
209// // Now define some Slicers, initially only specify the start
210// // Its length and stride will be 1.
211// Slicer ns0(IPosition(2,0,24));
212//
213// // make some IPositions as holders for the rest of the information
214// IPosition blc,trc,inc;
215//
216// // Use the shape and origin to fill our holders assuming we want to use
217// // as much of the Array as possible.
218// ns0.inferShapeFromSource (shape, origin, blc,trc,inc);
219//
220// // print out the new info ie. blc=[5,9],trc=[5,9],inc=[1,1]
221// cout << blc << trc << inc << endl;
222//
223// // Build a slicer with temporaries for arguments. The arguments are:
224// // start position, end position and step increment. The Slicer::endIsLast
225// // argument specifies that the end position is the trc. The alternative
226// // is Slicer::endIsLength which specifies that the end argument is the
227// // shape of the resulting subregion.
228// //
229// Slicer ns1(IPosition(2,3,5), IPosition(2,13,21), IPosition(2,3,2),
230// Slicer::endIsLast);
231// IPosition shp = ns1.inferShapeFromSource (shape, blc,trc,inc);
232// //
233// // print out the new info ie. shp=[4,9],blc=[3,5],trc=[12,21],inc=[3,2]
234// cout << shp << blc << trc << inc << endl;
235// </srcblock>
236// </ul>
237// </ul>
238
239// The <linkto module=Arrays:classes>detailed discussions</linkto> for the
240// classes and global functions will describe how to use them.
241// </synopsis>
242//
243// </module>
244
245} // namespace casacore
246
247#endif
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28