Skip to content

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

cpp
dMatrixNxN();

Default constructor. Creates empty matrix.

cpp
dMatrixNxN(const size_t N);

Constructor. Allocates matrix container of given size NxN.

cpp
dMatrixNxN(const size_t N, const double value);

Constructor. Allocates matrix container of given size NxN and initializes all of its elements with the given value.

cpp
dMatrixNxN(const dMatrixNxN& rhs);

Copy constructor. Creates the matrix and initializes it with the copy of the rhs.

cpp
void Allocate(const size_t N);

Allocates storage of empty container to the given size NxN.

cpp
void Allocate(const size_t N, const double value);

Allocates storage of empty container to given size NxN and initializes all of its elements with the given value.

Access operators

cpp
double& 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.

cpp
double 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.

cpp
double* data(void);

Returns the pointer to the stored data.

cpp
const double* const_data(void) const;

Returns const pointer to the stored data.

Arithmetic and matrix-vector operations

cpp
double norm(void) const;

Returns Frobenius norm of the matrix.

cpp
double determinant(void) const;

Returns determinant of the matrix.

cpp
bool is_singular(void) const;

Returns true if the current matrix is singular.

cpp
dMatrixNxN operator*(const double rhs) const;

Returns the copy of the current matrix with all its elements multiplied by rhs.

cpp
dMatrixNxN& operator*=(const double rhs);

Multiplies all entries of the current matrix by the rhs.

cpp
dMatrixNxN operator*(const dMatrixNxN& rhs) const;

Returns the product of the current matrix and the rhs matrix.

cpp
dVectorN operator*(const dVectorN& rhs) const;

Returns the product of the current matrix and the rhs vector.

cpp
dMatrixNxN operator+(const dMatrixNxN& rhs) const;

Returns the sum of the current matrix and the rhs matrix.

cpp
dMatrixNxN operator-(const dMatrixNxN& rhs) const;

Returns the difference of the current matrix and the rhs matrix.

cpp
dMatrixNxN& operator+=(const dMatrixNxN& rhs);

Adds rhs matrix to the current matrix.

cpp
dMatrixNxN& operator-=(const dMatrixNxN& rhs);

Subtracts rhs matrix from the current matrix.

cpp
dMatrixNxN operator/(const double rhs) const;

Returns the copy of the current matrix with all its elements divides by the scalar rhs.

cpp
dMatrixNxN& operator/=(const double rhs);

Divides all elements of the current matrix by the scalar rhs.

cpp
dMatrixNxN& operator=(const dMatrixNxN& rhs);

Assignment operator. Replaces the content of the current matrix with the copy of the rhs.

cpp
dMatrixNxN Hadamard_product(const dMatrixNxN& rhs) const;

Returns Hadamard (component-wise) product of the current matrix and the rhs.

cpp
dMatrixNxN inverted(void) const;

Returns inverted copy of the current matrix.

cpp
dMatrixNxN& invert(void);

Inverts the current matrix.

cpp
dMatrixNxN transposed(void) const;

Returns transposed copy of the current matrix.

cpp
dMatrixNxN& transpose(void);

Transposes the current matrix.

cpp
dMatrixNxN& set_to_zero(void);

Sets all elements of the current matrix to zero.

cpp
dMatrixNxN& set_to_unity(void);

Sets all elements of the current matrix to one.

cpp
dMatrixNxN& set_to_value(double value);

Sets all elements of the current matrix to the given value.

Container properties

cpp
size_t size(void) const;

Returns the size of the matrix.

cpp
size_t sizeX() const;

Returns the size of the first matrix dimension.

cpp
size_t sizeY() const;

Returns the size of the second matrix dimension.

Note: all three methods above return the same value.

MPI communication methods

cpp
void pack(std::vector<double>& buffer) const;

Packs (writes) matrix content into the MPI communication buffer.

cpp
void unpack(std::vector<double>& buffer, size_t& it);

Unpacks (reads) matrix content from the MPI communication buffer.

Read/write methods

cpp
std::string print(void) const;

Returns formatted string containing matrix elements for printing.

cpp
void read_binary(std::istream& inp);

Reads matrix content from the binary input stream inp.

cpp
void read_ASCII(std::istream& inp);

Reads matrix content from the ASCII input stream inp.

cpp
void write_binary(std::ostream& outp) const;

Writes matrix content to the binary output stream outp.

cpp
void 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.

cpp
std::string get_output_string(const int precision = std::numeric_limits<double>::digits10 + 1, const char sep = ' ') const;

Returns formatted string with the matrix content.

cpp
std::vector<double> get_vector() const;

Returns vector with flattened matrix content.

cpp
std::vector<float> get_vector_float() const;

Returns vector with float accuracy with flattened matrix content.

Released under the GNU GPLv3 License.