dMatrixNxN
dMatrixNxN is the dynamic storage container storing square matrix of double values. The size of the matrix can be set during run time.
The data inside of the dMatrixNxN container is manipulated using a number of dedicated methods:
Constructors
cppdMatrixNxN();Default constructor. Creates empty matrix.
cppdMatrixNxN(const size_t N);Constructor. Allocates matrix container of given size
NxN.
cppdMatrixNxN(const size_t N, const double value);Constructor. Allocates matrix container of given size
NxNand initializes all of its elements with the givenvalue.
cppdMatrixNxN(const dMatrixNxN& rhs);Copy constructor. Creates the matrix and initializes it with the copy of the
rhs.
cppvoid Allocate(const size_t N);Allocates storage of empty container to the given size
NxN.
cppvoid Allocate(const size_t N, const double value);Allocates storage of empty container to given size
NxNand initializes all of its elements with the givenvalue.
Access operators
cppdouble& operator()(const size_t n, const size_t m);Random access operator. Returns the reference to the element pointed to by the indices
n,m.
cppdouble const& operator()(const size_t n, const size_t m) const;Random access operator. Returns const reference to the element pointed to by the indices
n,m.
cppdouble* data(void);Returns the pointer to the stored data.
cppconst double* const_data(void) const;Returns const pointer to the stored data.
Arithmetic and matrix-vector operations
cppdouble norm(void) const;Returns Frobenius norm of the matrix.
cppdouble determinant(void) const;Returns determinant of the matrix.
cppbool is_singular(void) const;Returns true if the current matrix is singular.
cppdMatrixNxN operator*(const double rhs) const;Returns the copy of the current matrix with all its elements multiplied by
rhs.
cppdMatrixNxN& operator*=(const double rhs);Multiplies all entries of the current matrix by the
rhs.
cppdMatrixNxN operator*(const dMatrixNxN& rhs) const;Returns the product of the current matrix and the
rhsmatrix.
cppdVectorN operator*(const dVectorN& rhs) const;Returns the product of the current matrix and the
rhsvector.
cppdMatrixNxN operator+(const dMatrixNxN& rhs) const;Returns the sum of the current matrix and the
rhsmatrix.
cppdMatrixNxN operator-(const dMatrixNxN& rhs) const;Returns the difference of the current matrix and the
rhsmatrix.
cppdMatrixNxN& operator+=(const dMatrixNxN& rhs);Adds
rhsmatrix to the current matrix.
cppdMatrixNxN& operator-=(const dMatrixNxN& rhs);Subtracts
rhsmatrix from the current matrix.
cppdMatrixNxN operator/(const double rhs) const;Returns the copy of the current matrix with all its elements divides by the scalar
rhs.
cppdMatrixNxN& operator/=(const double rhs);Divides all elements of the current matrix by the scalar
rhs.
cppdMatrixNxN& operator=(const dMatrixNxN& rhs);Assignment operator. Replaces the content of the current matrix with the copy of the
rhs.
cppdMatrixNxN Hadamard_product(const dMatrixNxN& rhs) const;Returns Hadamard (component-wise) product of the current matrix and the
rhs.
cppdMatrixNxN inverted(void) const;Returns inverted copy of the current matrix.
cppdMatrixNxN& invert(void);Inverts the current matrix.
cppdMatrixNxN transposed(void) const;Returns transposed copy of the current matrix.
cppdMatrixNxN& transpose(void);Transposes the current matrix.
cppdMatrixNxN& set_to_zero(void);Sets all elements of the current matrix to zero.
cppdMatrixNxN& set_to_unity(void);Sets all elements of the current matrix to one.
cppdMatrixNxN& set_to_value(double value);Sets all elements of the current matrix to the given value.
Container properties
cppsize_t size(void) const;Returns the size of the matrix.
cppsize_t sizeX() const;Returns the size of the first matrix dimension.
cppsize_t sizeY() const;Returns the size of the second matrix dimension.
Note: all three methods above return the same value.
MPI communication methods
cppvoid pack(std::vector<double>& buffer) const;Packs (writes) matrix content into the MPI communication buffer.
cppvoid unpack(std::vector<double>& buffer, size_t& it);Unpacks (reads) matrix content from the MPI communication buffer.
Read/write methods
cppstd::string print(void) const;Returns formatted string containing matrix elements for printing.
cppvoid read_binary(std::istream& inp);Reads matrix content from the binary input stream
inp.
cppvoid read_ASCII(std::istream& inp);Reads matrix content from the ASCII input stream
inp.
cppvoid write_binary(std::ostream& outp) const;Writes matrix content to the binary output stream
outp.
cppvoid write_ASCII(std::ostream& outp, const int precision = std::numeric_limits<double>::digits10 + 1, const char sep = ' ') const;Writes matrix content to the ASCII output stream
outp.
cppstd::string get_output_string(const int precision = std::numeric_limits<double>::digits10 + 1, const char sep = ' ') const;Returns formatted string with the matrix content.
cppstd::vector<double> get_vector() const;Returns vector with flattened matrix content.
cppstd::vector<float> get_vector_float() const;Returns vector with float accuracy with flattened matrix content.