|
| Matrix (const Alloc &allocator=Alloc()) |
| A Matrix of length zero in each dimension; zero origin. More...
|
|
| Matrix (size_t l1, size_t l2, const T &initialValue=T(), const Alloc &allocator=Alloc()) |
| A Matrix with "l1" rows and "l2" columns. More...
|
|
| Matrix (size_t l1, size_t l2, typename Array< T, Alloc >::uninitializedType, const Alloc &allocator=Alloc()) |
| An uninitialized Matrix with "l1" rows and "l2" columns. More...
|
|
| Matrix (const IPosition &len, const T &initialValue=T(), const Alloc &allocator=Alloc()) |
| A matrix of shape with shape "len". More...
|
|
| Matrix (const IPosition &len, typename Array< T, Alloc >::uninitializedType, const Alloc &allocator=Alloc()) |
| An uninitialized matrix of shape with shape "len". More...
|
|
| Matrix (const Matrix< T, Alloc > &source) |
| The copy/move constructor uses reference semantics. More...
|
|
| Matrix (Matrix< T, Alloc > &&source) |
|
| Matrix (const Array< T, Alloc > &source) |
| Construct a Matrix by reference from "source". More...
|
|
| Matrix (Array< T, Alloc > &&source) |
|
| Matrix (const IPosition &shape, T *storage, StorageInitPolicy policy=COPY, const Alloc &allocator=Alloc()) |
| Create an Matrix of a given shape from a pointer. More...
|
|
| Matrix (const IPosition &shape, const T *storage) |
| Create an Matrix of a given shape from a pointer. More...
|
|
void | resize (size_t nx, size_t ny, bool copyValues=false) |
|
Matrix< T, Alloc > & | operator= (const Matrix< T, Alloc > &source) |
|
Matrix< T, Alloc > & | operator= (Matrix< T, Alloc > &&source) |
|
Matrix< T, Alloc > & | operator= (const Array< T, Alloc > &source) |
|
Matrix< T, Alloc > & | operator= (Array< T, Alloc > &&source) |
|
Matrix< T, Alloc > & | assign_conforming (const Matrix< T, Alloc > &source) |
| Copy the values from other to this Matrix. More...
|
|
Matrix< T, Alloc > & | assign_conforming (Matrix< T, Alloc > &&source) |
|
Matrix< T, Alloc > & | assign_conforming (const Array< T, Alloc > &source) |
|
Matrix< T, Alloc > & | assign_conforming (Array< T, Alloc > &&source) |
|
Array< T, Alloc > & | operator= (const T &val) |
| Copy val into every element of this Matrix; i.e. More...
|
|
Matrix< T, Alloc > & | assign_conforming (const MaskedArray< T > &marray) |
| Copy to this those values in marray whose corresponding elements in marray's mask are true. More...
|
|
T & | operator() (const IPosition &i) |
| Single-pixel addressing. More...
|
|
const T & | operator() (const IPosition &i) const |
|
T & | operator() (size_t i1, size_t i2) |
|
const T & | operator() (size_t i1, size_t i2) const |
|
MaskedArray< T > | operator() (const LogicalArray &mask) const |
| The array is masked by the input LogicalArray. More...
|
|
MaskedArray< T > | operator() (const LogicalArray &mask) |
| Return a MaskedArray. More...
|
|
MaskedArray< T > | operator() (const MaskedLogicalArray &mask) const |
| The array is masked by the input MaskedLogicalArray. More...
|
|
MaskedArray< T > | operator() (const MaskedLogicalArray &mask) |
| Return a MaskedArray. More...
|
|
Vector< T, Alloc > | row (size_t i) |
| Returns a reference to the i'th row. More...
|
|
const Vector< T, Alloc > | row (size_t i) const |
|
Vector< T, Alloc > | column (size_t j) |
| Returns a reference to the j'th column. More...
|
|
const Vector< T, Alloc > | column (size_t j) const |
|
Vector< T, Alloc > | diagonal (long long n=0) |
| Returns a diagonal from the Matrix. More...
|
|
const Vector< T, Alloc > | diagonal (long long n=0) const |
|
Matrix< T, Alloc > | operator() (const Slice &sliceX, const Slice &sliceY) |
| Take a slice of this matrix. More...
|
|
const Matrix< T, Alloc > | operator() (const Slice &sliceX, const Slice &sliceY) const |
|
Array< T, Alloc > | operator() (const IPosition &blc, const IPosition &trc, const IPosition &incr) |
| Slice using IPositions. More...
|
|
const Array< T, Alloc > | operator() (const IPosition &blc, const IPosition &trc, const IPosition &incr) const |
|
Array< T, Alloc > | operator() (const IPosition &blc, const IPosition &trc) |
|
const Array< T, Alloc > | operator() (const IPosition &blc, const IPosition &trc) const |
|
Array< T, Alloc > | operator() (const Slicer &slicer) |
|
const Array< T, Alloc > | operator() (const Slicer &slicer) const |
|
const IPosition & | shape () const |
| The length of each axis of the Matrix. More...
|
|
void | shape (int &s1, int &s2) const |
|
size_t | nrow () const |
| The number of rows in the Matrix, i.e. More...
|
|
size_t | ncolumn () const |
| The number of columns in the Matrix, i.e. More...
|
|
virtual bool | ok () const override |
| Checks that the Matrix is consistent (invariants check out). More...
|
|
| Array (const Alloc &allocator=Alloc()) |
| Result has dimensionality of zero, and nelements is zero. More...
|
|
| Array (const IPosition &shape, const Alloc &allocator=Alloc()) |
| Create an array of the given shape, i.e. More...
|
|
| Array (const IPosition &shape, const T &initialValue, const Alloc &allocator=Alloc()) |
| Create an array of the given shape and initialize it with the initial value. More...
|
|
| Array (const IPosition &shape, uninitializedType, const Alloc &allocator=Alloc()) |
| Constructor to create an uninitialized array. More...
|
|
| Array (std::initializer_list< T > list, const Alloc &allocator=Alloc()) |
| Construct a one-dimensional array from an initializer list. More...
|
|
| Array (const Array< T, Alloc > &other) |
| After construction, this and other reference the same storage. More...
|
|
| Array (Array< T, Alloc > &&source) noexcept |
| Source will be empty after this call. More...
|
|
| Array (const IPosition &shape, T *storage, StorageInitPolicy policy=COPY, const Alloc &allocator=Alloc()) |
| Create an Array of a given shape from a pointer. More...
|
|
| Array (const IPosition &shape, const T *storage) |
| Create an Array of a given shape from a pointer. More...
|
|
template<typename InputIterator > |
| Array (const IPosition &shape, InputIterator startIter, const Alloc &allocator=Alloc()) |
| Construct an array from an iterator and a shape. More...
|
|
virtual | ~Array () noexcept |
| Frees up storage only if this array was the last reference to it. More...
|
|
virtual std::unique_ptr
< ArrayBase > | makeArray () const override |
| Make an empty array of the same template type. More...
|
|
void | assign (const Array< T, Alloc > &other) |
| Assign the other array to this array. More...
|
|
void | assignBase (const ArrayBase &other, bool checkType=true) override |
| Assign the source array to this array. More...
|
|
void | set (const T &value) |
| Set every element of the array to "value." Also could use the assignment operator which assigns an array from a scalar. More...
|
|
template<typename Callable > |
void | apply (Callable function) |
| Apply the function to every element of the array. More...
|
|
virtual void | reference (const Array< T, Alloc > &other) |
| After invocation, this array and other reference the same storage. More...
|
|
Array< T, Alloc > & | assign_conforming (const Array< T, Alloc > &other) |
| Copy the values in other to this. More...
|
|
template<typename MaskAlloc > |
Array< T, Alloc > & | assign_conforming (const MaskedArray< T, Alloc, MaskAlloc > &marray) |
| Copy to this those values in marray whose corresponding elements in marray's mask are true. More...
|
|
Array< T, Alloc > & | operator= (const Array< T, Alloc > &other) |
| TODO we should change the semantics. More...
|
|
template<typename MaskAlloc > |
Array< T, Alloc > & | operator= (const MaskedArray< T, Alloc, MaskAlloc > &marray) |
| Calls assign_conforming(). More...
|
|
Array< T, Alloc > & | operator= (Array< T, Alloc > &&other) |
| The move operator takes the storage from the given array. More...
|
|
Array< T, Alloc > & | operator= (const T &value) |
| Set every element of this array to "value". More...
|
|
Array< T, Alloc > | copy () const |
| This makes a copy of the array and returns it. More...
|
|
void | copyMatchingPart (const Array< T, Alloc > &from) |
| This function copies the matching part of from array to this array. More...
|
|
void | unique () |
| This ensures that this array does not reference any other storage. More...
|
|
template<class U > |
void | tovector (std::vector< T, U > &out) const |
| Create an STL vector from an Array. More...
|
|
std::vector< T > | tovector () const |
|
Array< T, Alloc > | reform (const IPosition &shape) const |
| It is occasionally useful to have an array which access the same storage appear to have a different shape. More...
|
|
bool | reformOrResize (const IPosition &newShape, size_t resizePercentage=0, bool resizeIfNeeded=true) |
| Having an array that can be reused without requiring reallocation can be useful for large arrays. More...
|
|
bool | adjustLastAxis (const IPosition &newShape, size_t resizePercentage=0, bool resizeIfNeeded=true) |
| Use this method to extend or reduce the last dimension of an array. More...
|
|
size_t | capacity () const |
| Returns the number of elements allocated. More...
|
|
Array< T, Alloc > | nonDegenerate (size_t startingAxis=0, bool throwIfError=true) const |
| These member functions remove degenerate (ie. More...
|
|
Array< T, Alloc > | nonDegenerate (const IPosition &ignoreAxes) const |
|
void | nonDegenerate (const Array< T, Alloc > &other, size_t startingAxis=0, bool throwIfError=true) |
|
void | nonDegenerate (const Array< T, Alloc > &other, const IPosition &ignoreAxes) |
|
void | removeDegenerate (size_t startingAxis=0, bool throwIfError=true) |
| Remove degenerate axes from this Array object. More...
|
|
void | removeDegenerate (const IPosition &ignoreAxes) |
|
const Array< T, Alloc > | addDegenerate (size_t numAxes) const |
| This member function returns an Array reference with the specified number of extra axes, all of length one, appended to the end of the Array. More...
|
|
Array< T, Alloc > | addDegenerate (size_t numAxes) |
|
void | resize () |
| Make this array a different shape. More...
|
|
void | resize (const IPosition &newShape, bool copyValues=false) override |
| Resize the array and optionally copy the values. More...
|
|
T & | operator() (const IPosition &) |
| Access a single element of the array. More...
|
|
const T & | operator() (const IPosition &) const |
|
Array< T, Alloc > | operator() (const IPosition &start, const IPosition &end) |
| Get a reference to an array section extending from start to end (inclusive). More...
|
|
const Array< T, Alloc > | operator() (const IPosition &start, const IPosition &end) const |
|
Array< T, Alloc > | operator() (const IPosition &start, const IPosition &end, const IPosition &inc) |
| Along the ith axis, every inc[i]'th element is chosen. More...
|
|
const Array< T, Alloc > | operator() (const IPosition &start, const IPosition &end, const IPosition &inc) const |
|
Array< T, Alloc > | operator() (const Slicer &) |
| Get a reference to an array section using a Slicer. More...
|
|
const Array< T, Alloc > | operator() (const Slicer &) const |
|
std::unique_ptr< ArrayBase > | getSection (const Slicer &) const override |
| Get a reference to a section of an array. More...
|
|
Array< T, Alloc > | operator[] (size_t i) const |
| Get the subset given by the i-th value of the last axis. More...
|
|
Array< T, Alloc > | diagonals (size_t firstAxis=0, long long diag=0) const |
| Get the diagonal of each matrix part in the full array. More...
|
|
const MaskedArray< T > | operator() (const LogicalArray &mask) const |
| The array is masked by the input LogicalArray. More...
|
|
MaskedArray< T > | operator() (const LogicalArray &mask) |
|
const MaskedArray< T > | operator() (const MaskedLogicalArray &mask) const |
| The array is masked by the input MaskedLogicalArray. More...
|
|
MaskedArray< T > | operator() (const MaskedLogicalArray &mask) |
|
size_t | nrefs () const |
| The number of references the underlying storage has assigned to it. More...
|
|
bool | conform (const Array< T, Alloc > &other) const |
| Are the shapes identical? More...
|
|
bool | conform (const MaskedArray< T > &other) const |
|
T * | data () |
| Get a pointer to the beginning of the array. More...
|
|
const T * | data () const |
|
T * | getStorage (bool &deleteIt) |
| Generally use of this should be shunned, except to use a FORTRAN routine or something similar. More...
|
|
const T * | getStorage (bool &deleteIt) const |
|
void * | getVStorage (bool &deleteIt) override |
| The following functions behave the same as the corresponding getStorage functions in the derived templated Array class. More...
|
|
const void * | getVStorage (bool &deleteIt) const override |
|
void | putStorage (T *&storage, bool deleteAndCopy) |
| putStorage() is normally called after a call to getStorage() (cf). More...
|
|
void | putVStorage (void *&storage, bool deleteAndCopy) override |
|
void | freeStorage (const T *&storage, bool deleteIt) const |
| If deleteIt is set, delete "storage". More...
|
|
void | freeVStorage (const void *&storage, bool deleteIt) const override |
|
virtual void | takeStorage (const IPosition &shape, T *storage, StorageInitPolicy policy=COPY, const Alloc &allocator=Alloc()) |
| Replace the data values with those in the pointer storage . More...
|
|
virtual void | takeStorage (const IPosition &shape, const T *storage, const Alloc &allocator=Alloc()) |
| Since the pointer is const, a copy is always taken. More...
|
|
std::unique_ptr
< ArrayPositionIterator > | makeIterator (size_t byDim) const override |
| Create an ArrayIterator object of the correct type. More...
|
|
Alloc & | allocator () |
| Retrieve the allocator associated with this array. More...
|
|
const Alloc & | allocator () const |
|
iterator | begin () |
| Get the begin iterator object for any array. More...
|
|
const_iterator | begin () const |
|
iterator | end () |
|
const_iterator | end () const |
|
contiter | cbegin () |
| Get the begin iterator object for a contiguous array. More...
|
|
const_contiter | cbegin () const |
|
contiter | cend () |
|
const_contiter | cend () const |
|
| ArrayBase () noexcept |
|
| ArrayBase (const IPosition &shape) |
| Create an array of the given shape, i.e. More...
|
|
| ArrayBase (const ArrayBase &other) |
| Copy constructor. More...
|
|
| ArrayBase (ArrayBase &&source) noexcept |
|
ArrayBase & | assign (const ArrayBase &) |
| Assignment. More...
|
|
ArrayBase & | operator= (const ArrayBase &)=delete |
|
ArrayBase & | operator= (ArrayBase &&) noexcept |
|
virtual | ~ArrayBase () noexcept |
| Destructor. More...
|
|
size_t | ndim () const |
| The dimensionality of this array. More...
|
|
size_t | nelements () const |
| How many elements does this array have? Product of all axis lengths. More...
|
|
size_t | size () const |
|
bool | empty () const |
| Is the array empty (i.e. More...
|
|
bool | contiguousStorage () const |
| Are the array data contiguous? If they are not contiguous, getStorage (see below) needs to make a copy. More...
|
|
const IPosition & | shape () const |
| The length of each axis. More...
|
|
IPosition | endPosition () const |
| A convenience function: endPosition(i) = shape(i) - 1; i.e. More...
|
|
const IPosition & | steps () const |
| Return steps to be made if stepping one element in a dimension. More...
|
|
void | validateConformance (const ArrayBase &) const |
| Various helper functions. More...
|
|
void | validateIndex (const IPosition &) const |
|
void | validateIndex (size_t index) const |
|
void | validateIndex (size_t index1, size_t index2) const |
|
void | validateIndex (size_t index1, size_t index2, size_t index3) const |
|
template<typename T, typename Alloc = std::allocator<T>>
class casacore::Matrix< T, Alloc >
A 2-D Specialization of the Array class.
Review Status
- Reviewed By:
- UNKNOWN
- Date Reviewed:
- before2004/08/25
Matrix objects are two-dimensional specializations (e.g., more convenient and efficient indexing) of the general Array class. You might also want to look at the Array documentation to see inherited functionality. A tutorial on using the array classes in general is available in the "AIPS++ Programming Manual".
Generally the member functions of Array are also available in Matrix versions which take a pair of integers where the array needs an IPosition. Since the Matrix is two-dimensional, the IPositions are overkill, although you may use those versions if you want to.
Matrix<int> mi(100,100);
mi.resize(50,50);
Slices may be taken with the Slice class. To take a slice, one "indexes" with one Slice(start, length, inc) for each axis, where end and inc are optional. Additionally, there are row(), column() and diagonal() member functions which return Vector's which refer to the storage back in the Matrix:
Matrix<float> mf(100, 100);
mf.diagonal() = 1;
Correct indexing order of a matrix is:
Matrix<int> mi(n1,n2)
for (size_t i=0; i<mi.nrow(); i++) {
mi(i,j) = i*j;
}
}
Element-by-element arithmetic and logical operations are available (in aips/ArrayMath.h and aips/ArrayLogical.h). Other Matrix operations (e.g. LU decomposition) are available, and more appear periodically.
As with the Arrays, if the preprocessor symbol AIPS_DEBUG is defined at compile time invariants will be checked on entry to most member functions. Additionally, if AIPS_ARRAY_INDEX_CHECK is defined index operations will be bounds-checked. Neither of these should be defined for production code.
Definition at line 10 of file ArrayFwd.h.