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());
99 Matrix(
size_t l1,
size_t l2,
typename Array<T, Alloc>::uninitializedType,
const Alloc&
allocator = Alloc());
103 Matrix(
const IPosition &len,
const T &initialValue = T(),
const Alloc&
allocator = Alloc());
106 Matrix(
const IPosition &len,
typename Array<T, Alloc>::uninitializedType,
const Alloc&
allocator = Alloc());
109 Matrix(
const Matrix<T, Alloc>& source);
110 Matrix(Matrix<T, Alloc>&& source);
114 Matrix(
const Array<T, Alloc>& source);
115 Matrix(Array<T, Alloc>&& source);
121 Matrix(
const IPosition &shape,
const T *storage);
125 static Matrix<T, Alloc>
identity (
size_t n);
129 using Array<T, Alloc>::resize;
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"
A Vector of integers, for indexing into Array<T> objects.
size_t xinc() const
Cached constants to improve indexing.
T & operator()(const IPosition &i)
Single-pixel addressing.
A 1-D Specialization of the Array class.
void shape(int &s1, int &s2) const
T & operator()(size_t i1, size_t i2)
bool contiguous_p
Are the data contiguous?
size_t nrow() const
The number of rows in the Matrix, i.e.
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
Matrix< T, Alloc > & operator=(Array< T, Alloc > &&source)
Array< T, Alloc > operator()(const IPosition &blc, const IPosition &trc, const IPosition &incr)
Slice using IPositions.
static Matrix< T, Alloc > identity(size_t n)
Create an identity matrix of side length n.
IPosition originalLength_p
Array< T, Alloc > & operator=(const Array< T, Alloc > &other)
TODO we should change the semantics.
const T & operator()(size_t i1, size_t i2) const
Vector< T, Alloc > column(size_t j)
Returns a reference to the j'th column.
StorageInitPolicy
A global enum used by some Array constructors.
const IPosition & shape() const
The length of each axis of the Matrix.
const Array< T, Alloc > operator()(const IPosition &blc, const IPosition &trc) const
size_t ncolumn() const
The number of columns in the Matrix, i.e.
A 2-D Specialization of the Array class.
TableExprNode marray(const TableExprNode &array, const TableExprNode &mask)
Form a masked array.
Matrix(const Alloc &allocator=Alloc())
A Matrix of length zero in each dimension; zero origin.
size_t ndim() const
The dimensionality of this array.
virtual bool ok() const override
Checks that the Matrix is consistent (invariants check out).
IPosition length_p
Used to hold the shape, increment into the underlying storage and originalLength of the array...
virtual size_t fixedDimensionality() const override
Subclasses can return their dimensionality.
virtual void preTakeStorage(const IPosition &shape) override
pre/post processing hook of takeStorage() for subclasses.
Class for masking an Array for operations on that Array.
T & operator()(const IPosition &)
Access a single element of the array.
Matrix< T, Alloc > & operator=(Matrix< T, Alloc > &&source)
Array< T, Alloc > operator()(const Slicer &slicer)
Vector< T, Alloc > row(size_t i)
Returns a reference to the i'th row.
const Array< T, Alloc > operator()(const Slicer &slicer) const
const Array< T, Alloc > operator()(const IPosition &blc, const IPosition &trc, const IPosition &incr) const
define a (start,length,increment) along an axis
const T & operator()(const IPosition &i) const
T * begin_p
This pointer is adjusted to point to the first element of the array.
Matrix< T, Alloc > & operator=(const Matrix< T, Alloc > &source)
Alloc & allocator()
Retrieve the allocator associated with this array.
Array< T, Alloc > operator()(const IPosition &blc, const IPosition &trc)
Matrix< T, Alloc > & assign_conforming(const Array< T, Alloc > &source)
Vector< T, Alloc > diagonal(long long n=0)
Returns a diagonal from the Matrix.
A templated N-D Array class with zero origin. Array<T, Alloc> is a templated, N-dimensional, Array class. The origin is zero, but by default indices are zero-based. This Array class is the base class for the Vector, Matrix, and Cube subclasses.
Array< T, Alloc > & operator=(const T &val)
Copy val into every element of this Matrix; i.e.
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...
Specify which elements to extract from an n-dimensional array.
Matrix< T, Alloc > & assign_conforming(Array< T, Alloc > &&source)
Array< T, Alloc > & assign_conforming(const Array< T, Alloc > &other)
Copy the values in other to this.
COPY is used when an internal copy of the storage is to be made.
Matrix< T, Alloc > & assign_conforming(const Matrix< T, Alloc > &source)
Copy the values from other to this Matrix.
void resize()
Make this array a different shape.
virtual void doNonDegenerate(const Array< T, Alloc > &other, const IPosition &ignoreAxes) override
Remove the degenerate axes from other and store result in this matrix.
Matrix< T, Alloc > & assign_conforming(Matrix< T, Alloc > &&source)
Matrix< T, Alloc > & operator=(const Array< T, Alloc > &source)