28 #ifndef CASA_MATRIX_2_H
29 #define CASA_MATRIX_2_H
88 template<
typename T,
typename Alloc>
class Matrix :
public Array<T, Alloc>
96 Matrix(
size_t l1,
size_t l2,
const T &initialValue = T(),
const Alloc&
allocator = Alloc());
130 void resize(
size_t nx,
size_t ny,
bool copyValues=
false);
158 if (source.
ndim() == 2) {
169 if (source.ndim() == 2) {
308 virtual bool ok()
const override;
329 extern template class Matrix<bool>;
330 extern template class Matrix<float>;
331 extern template class Matrix<double>;
335 #include "Matrix.tcc"
size_t ndim() const
The dimensionality of this array.
bool contiguous_p
Are the data contiguous?
IPosition originalLength_p
IPosition length_p
Used to hold the shape, increment into the underlying storage and originalLength of the array.
T & operator()(const IPosition &)
Access a single element of the array.
T * begin_p
This pointer is adjusted to point to the first element of the array.
Alloc & allocator()
Retrieve the allocator associated with this array.
Array< T, Alloc > & operator=(const Array< T, Alloc > &other)
TODO we should change the semantics.
Array< T, Alloc > & assign_conforming(const Array< T, Alloc > &other)
Copy the values in other to this.
Matrix< T, Alloc > & assign_conforming(Matrix< T, Alloc > &&source)
const Vector< T, Alloc > row(size_t i) const
Matrix< T, Alloc > & operator=(Array< T, Alloc > &&source)
Array< T, Alloc > operator()(const Slicer &slicer)
virtual size_t fixedDimensionality() const override
Subclasses can return their dimensionality.
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.
Array< T, Alloc > operator()(const IPosition &blc, const IPosition &trc, const IPosition &incr)
Slice using IPositions.
Matrix< T, Alloc > & assign_conforming(Array< T, Alloc > &&source)
Matrix< T, Alloc > operator()(const Slice &sliceX, const Slice &sliceY)
Take a slice of this matrix.
void shape(int &s1, int &s2) const
const IPosition & shape() const
The length of each axis of the Matrix.
Matrix< T, Alloc > & assign_conforming(const Array< T, Alloc > &source)
const T & operator()(const IPosition &i) const
Matrix(const IPosition &len, const T &initialValue=T(), const Alloc &allocator=Alloc())
A matrix of shape with shape "len".
Vector< T, Alloc > row(size_t i)
Returns a reference to the i'th row.
size_t ncolumn() const
The number of columns in the Matrix, i.e.
const Array< T, Alloc > operator()(const IPosition &blc, const IPosition &trc, const IPosition &incr) const
const Vector< T, Alloc > column(size_t j) const
Matrix(Matrix< T, Alloc > &&source)
Matrix< T, Alloc > & operator=(const Matrix< T, Alloc > &source)
const Array< T, Alloc > operator()(const Slicer &slicer) const
const Matrix< T, Alloc > operator()(const Slice &sliceX, const Slice &sliceY) const
size_t nrow() const
The number of rows in the Matrix, i.e.
Matrix(size_t l1, size_t l2, const T &initialValue=T(), const Alloc &allocator=Alloc())
A Matrix with "l1" rows and "l2" columns.
virtual bool ok() const override
Checks that the Matrix is consistent (invariants check out).
virtual void doNonDegenerate(const Array< T, Alloc > &other, const IPosition &ignoreAxes) override
Remove the degenerate axes from other and store result in this matrix.
T & operator()(const IPosition &i)
Single-pixel addressing.
const T & operator()(size_t i1, size_t i2) const
Matrix(Array< T, Alloc > &&source)
static Matrix< T, Alloc > identity(size_t n)
Create an identity matrix of side length n.
Matrix(const IPosition &shape, T *storage, StorageInitPolicy policy=COPY, const Alloc &allocator=Alloc())
Create an Matrix of a given shape from a pointer.
const Vector< T, Alloc > diagonal(long long n=0) const
Matrix(const IPosition &shape, const T *storage)
Create an Matrix of a given shape from a pointer.
T & operator()(size_t i1, size_t i2)
size_t xinc() const
Cached constants to improve indexing.
Matrix< T, Alloc > & operator=(Matrix< T, Alloc > &&source)
Matrix(const Matrix< T, Alloc > &source)
The copy/move constructor uses reference semantics.
Matrix< T, Alloc > & operator=(const Array< T, Alloc > &source)
Matrix(const Array< T, Alloc > &source)
Construct a Matrix by reference from "source".
virtual void preTakeStorage(const IPosition &shape) override
pre/post processing hook of takeStorage() for subclasses.
Vector< T, Alloc > column(size_t j)
Returns a reference to the j'th column.
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.
Matrix< T, Alloc > & assign_conforming(const Matrix< T, Alloc > &source)
Copy the values from other to this Matrix.
Matrix(const IPosition &len, typename Array< T, Alloc >::uninitializedType, const Alloc &allocator=Alloc())
An uninitialized matrix of shape with shape "len".
Matrix(const Alloc &allocator=Alloc())
A Matrix of length zero in each dimension; zero origin.
const Array< T, Alloc > operator()(const IPosition &blc, const IPosition &trc) const
Vector< T, Alloc > diagonal(long long n=0)
Returns a diagonal from the Matrix.
Array< T, Alloc > operator()(const IPosition &blc, const IPosition &trc)
Array< T, Alloc > & operator=(const T &val)
Copy val into every element of this Matrix; i.e.
void resize(size_t nx, size_t ny, bool copyValues=false)
@ COPY
COPY is used when an internal copy of the storage is to be made.
this file contains all the compiler specific defines
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
TableExprNode marray(const TableExprNode &array, const TableExprNode &mask)
Form a masked array.
This is a tag for the constructor that may be used to construct an uninitialized Array.