Matrix
Matrix<T> is a templated storage container for storing numerical data. It can handle any type T of values except bool but is recommended for the arithmetic types. For storing bool vdata and other uses see Table container.
The data inside of the Matrix container is manipulated using a number of dedicated methods:
Constructors
cppMatrix();Default constructor. Constructs empty matrix.
cppMatrix(const Matrix<T>& rhs);Copy constructor. Initializes current container with the copy of
rhs.
cppMatrix(const size_t N, const size_t M);Constructor. Allocates internal storage to the specified dimensions
(N,M).
cppvoid Allocate(const size_t N, const size_t M);Allocates internal storage to the specified table dimensions (N,M).
cppvoid Reallocate(const size_t N, const size_t M);Reallocates internal storage to new dimensions. Previously stored data is erased.
Data access and manipulation
cppT const& operator()(const size_t n, const size_t m) const;One-directional access operator. Returns constant reference to the matrix element
(n,m).
cppT& operator()(const size_t n, const size_t m);Bi-directional access operator. Returns reference to the matrix element
(n,m).
cppvoid set(const size_t n, const size_t m, const T value);Sets matrix element
(n,m)to the specified value.
cppvoid set_to_value(const T value);Sets all matrix elements to the specified value.
cppvoid add(const size_t n, const size_t m, const T value);Adds value to the matrix element
(n,m).
cppT get(const size_t n, const size_t m) const;Returns the value of the matrix element
(n,m).
cppT get_min() const;Returns the value of the minimum element of the matrix.
cppT get_max() const;Returns the value of the maximum element of the matrix.
cpp>static Matrix<T> max(const Matrix<T>& M1, const Matrix<T>& M2);Returns matrix containing maximum elements between the two matrices.
cppstatic Matrix<T> min(const Matrix<T>& M1, const Matrix<T>& M2);Returns matrix containing minimum elements between the two matrices.
cppT* data();Raw data access.
Container properties
cppsize_t size_tot();Total size of the internal storage.
cppsize_t sizeN() const;Returns first dimension of the stored matrix.
cppsize_t sizeM() const;Returns second dimension of the stored matrix.
cppbool IsNotAllocated() const;Returns true if matrix is not allocated (internal storage size is zero).
cppbool IsAllocated() const;Returns true if matrix is allocated (internal storage size is not zero).
Arithmetic operations
cppMatrix<T> operator*(const Matrix<T>& rhs) const;Returns matrix dot product between the current matrix and
rhs.
cppMatrix<T> operator+(const Matrix<T>& rhs);Returns a matrix containing the sum of two matrices.
cppMatrix<T>& operator+=(const Matrix<T>& rhs);Adds
rhsto the current matrix. For empty matrices assumes zeros.
cppMatrix<T>& operator=(const Matrix<T>& rhs);Assignment operator. Assigns the content of
rhsto the current matrix.
Output
cppstd::string print(void) const;Returns formatted string with matrix content.