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
62
63namespace casacore { //# NAMESPACE CASACORE - BEGIN
64
65// <module>
66//
67// <summary>
68// A module implementing multidimensional arrays and operations.
69// </summary>
70
71// <reviewed reviewer="UNKNOWN" date="before2004/08/25" demos="">
72// </reviewed>
73
74// <etymology>
75// This module provides classes and global functions for multidimensional
76// arrays.
77// </etymology>
78//
79// <synopsis>
80// Arrays have traditionally played an important role in scientific
81// computation. While it is certainly true that some of the reliance on
82// arrays was due to the paucity of other data structures in FORTRAN, it
83// is also true that computation on arrays reflects the common occurrence
84// of regularly sampled multi-dimensioned data in science.
85//
86// The <linkto module=Lattices>Lattices</linkto> are a generalization
87// of Arrays. They can handle memory- and disk-based arrays as well
88// as other types of arrays (eg. expressions).
89//
90// The module consists of various parts:
91// <ul>
92
93// <li>
94// <linkto class=Array>Array</linkto> is the basic array class. It is
95// only templated on data type, not on dimensionality like the array
96// classes in Blitz and boost.
97// It has a non-templated base class ArrayBase.
98//
99// <linkto class=Vector>Vector</linkto>,
100// <linkto class=Matrix>Matrix</linkto>, and
101// <linkto class=Cube>Cube</linkto>
102// are the one, two, and three dimensional specializations respectively of
103// Array.
104//
105// <li>
106// <linkto class=MaskedArray>MaskedArray</linkto> is the class used to mask
107// an Array for operations on that Array.
108//
109// <li>
110// <linkto class=ArrayError>ArrayError</linkto> is the base class for all
111// Array exception classes.
112//
113// <li>
114// There are several ways o iterate through an array:
115// <ul>
116// <li> The STL-style Array iterators can be used to iterate
117// element by element through an array. This is the fastest way.
118// They also make it possible to virtually extend an array (called
119// shape broadcasting in numpy) and to reorder the iteration axes.
120// <li> <linkto class=ArrayIterator>ArrayIterator</linkto> can be used to
121// iterate line by line, plane by plane, etc. through an array.
122// Each subset is an array in itself, thus can be iterated again.
123// <li> The Array function operators () can be used to get a subset from
124// an array. They can be used for iteration, but that is slower than
125// the ways mentioned above.
126// <li> The array operator[] can be used to get the i-th subset. It can
127// be used for iteration, but ArrayIterator does the same and is faster.
128// <li> ArrayAccessor is useful when neighbours of an array element have
129// to be visited.
130// <li> <linkto class=LatticeIterator>LatticeIterator</linkto> can be used on
131// a <linkto class=ArrayLattice>ArrayLattice</linkto> object for more
132// advanced iteration. However, they are part of the lattices packages.
133// </ul>
134//
135// <li>
136// <linkto group="ArrayMath.h#Array mathematical operations">Mathematical</linkto>,
137// <linkto group="ArrayLogical.h#Array logical operations">logical</linkto>,
138// <linkto group="ArrayPartMath.h#Array partial operations">chunked mathematical and logical</linkto>,
139// <linkto group="ArrayIO.h#Array IO">IO</linkto>,
140// and other useful operations are provided for
141// Arrays and MaskedArrays.
142//
143// ArrayMath also defines various STL-style transform functions that use the
144// Array iterators and functors like Plus to apply the mathematical and logical
145// operations. They can, however, also be used directly on arrays of
146// different types making it possible to, say, add a Complex and double array
147// with a DComplex result.
148// <br>It also has a <src>transformInPlace</src> to avoid needless incrementing
149// of iterators which have to be done when using <src>std::transform</src>
150// for in-place operations.
151//
152// <li>
153// Orthogonal n-space descriptors - useful when a shape of an Array is
154// needed or when a sub-region within an Array is required.
155// <ul>
156// <li> The <linkto class="IPosition">IPosition</linkto> class name is a
157// concatenation of "Integer Position." IPosition objects are normally
158// used to index into, and define the shapes of, Arrays and Lattices. For
159// example, if you have a 5-dimensional array, you need an IPosition of
160// length 5 to index into the array (or to define its shape, etc.). It is
161// essentially a vector of integers. The IPosition vector may point to
162// the "top right corner" of some shape, or it may be an indicator of a
163// specific position in n-space. The interpretation is context dependent.
164// The constructor consists of an initial argument which specifies the
165// number of axes, followed by the appropriate number of respective axis
166// lengths. Thus the constructor needs N+1 arguments for an IPosition
167// of length N. IPositions have the standard integer math relationships
168// defined. The dimensionality of the operator arguments must be the
169// same.
170//<srcblock>
171// // Make a shape with three axes, x = 24, y = 48, z = 16;
172// IPosition threeSpace(3, 24, 48, 16);
173//
174// // get the value of the ith axis (note: C++ is zero based!)
175// Int xShape = threeSpace(0);
176// Int zShape = threeSpace(2);
177//
178// // construct another with all three axes values equal to 666;
179// IPosition threeSpaceAlso(3,666);
180//
181// // do math with the IPositions...
182// threeSpace += threeSpaceAlso;
183// AlwaysAssert(threeSpace(1) == 714, AipsError);
184// </srcblock>
185//
186// <li> The <linkto class="Slicer">Slicer</linkto> class name may be
187// thought of as a short form of "n-Dimensional Slice Specifier."
188// This object is used to bundle into one place all the information
189// necessary to specify a regular subregion within an Array or Lattice.
190// In other words, Slicer holds the location of a "slice" of a
191// greater whole. Construction is with up to 3 IPositions: the start
192// location of the subspace within the greater space; the shape or end
193// location of the subspace within the greater space; and the stride,
194// or multiplier to be used for each axis. The stride gives the user
195// the chance to use every i-th piece of data, rather than every
196// position on the axis.
197// <br>
198// It is possible to leave some values in the given start or end/length
199// unspecified. Such unspecified values default to the boundaries of the
200// array to which the slicer will be applied.
201// It is also possible to use a non-zero origin when applying the slicer
202// to an array.
203//
204// <srcblock>
205// // Define the shape of an array.
206// IPosition shape(2,20,30);
207//
208// // Also define an origin.
209// IPosition origin(2,-5,15);
210//
211// // Now define some Slicers, initially only specify the start
212// // Its length and stride will be 1.
213// Slicer ns0(IPosition(2,0,24));
214//
215// // make some IPositions as holders for the rest of the information
216// IPosition blc,trc,inc;
217//
218// // Use the shape and origin to fill our holders assuming we want to use
219// // as much of the Array as possible.
220// ns0.inferShapeFromSource (shape, origin, blc,trc,inc);
221//
222// // print out the new info ie. blc=[5,9],trc=[5,9],inc=[1,1]
223// cout << blc << trc << inc << endl;
224//
225// // Build a slicer with temporaries for arguments. The arguments are:
226// // start position, end position and step increment. The Slicer::endIsLast
227// // argument specifies that the end position is the trc. The alternative
228// // is Slicer::endIsLength which specifies that the end argument is the
229// // shape of the resulting subregion.
230// //
231// Slicer ns1(IPosition(2,3,5), IPosition(2,13,21), IPosition(2,3,2),
232// Slicer::endIsLast);
233// IPosition shp = ns1.inferShapeFromSource (shape, blc,trc,inc);
234// //
235// // print out the new info ie. shp=[4,9],blc=[3,5],trc=[12,21],inc=[3,2]
236// cout << shp << blc << trc << inc << endl;
237// </srcblock>
238// </ul>
239// </ul>
240
241// The <linkto module=Arrays:classes>detailed discussions</linkto> for the
242// classes and global functions will describe how to use them.
243// </synopsis>
244//
245// </module>
246
247
248} //# NAMESPACE CASACORE - END
249
250#endif
this file contains all the compiler specific defines
Definition mainpage.dox:28