Skip to content

dMatrix3x3

dMatrix3x3 is a static storage container which stores a three by three matrix of double values. It is used to store deformation tensors, rotation matrices, transformation tensors, etc., as a storage unit in Storage3D container.

The data inside of the dMatrix3x3 container is manipulated using a number of dedicated methods:

Constructors

cpp
dMatrix3x3();

Default constructor, sets matrix values to zero;

cpp
dMatrix3x3(const dMatrix3x3& rhs);

Copy constructor, initializes the current matrix with a copy of rhs.

cpp
dMatrix3x3(std::initializer_list<double> matinit);

Constructor, initializes the current matrix using initializer list matinit.

cpp
static dMatrix3x3 ZeroTensor(void);

Constructs and returns zero-valued matrix.

cpp
static dMatrix3x3 UnitTensor(void);

Constructs and returns diagonal unity matrix.

Access operators

cpp
double& operator()(const size_t i, const size_t j);
double const& operator()(const size_t i, const size_t j) const;

Return (const) reference to the element i,j.

cpp
double* data(void);
const double* data(void) const;

Returns (const) pointer to the first element of the vector.

Logic, arithmetic and matrix-vector operations

cpp
bool operator==(const dMatrix3x3& rhs);

Boolean comparison operator. Returns true if element-wise difference of the two matrices is smaller than DBL_EPSILON.

cpp
bool operator!=(const dMatrix3x3& rhs);

Boolean comparison operator. Returns true if element-wise difference of the two matrices is greater than DBL_EPSILON.

cpp
dMatrix3x3 operator*(const double m) const;

Returns current matrix with all components multiplied by the factor m.

cpp
dMatrix3x3 operator/(const double m) const;

Returns current matrix with all components divided by the factor m.

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

Returns dot product of two matrices.

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

Returns the sum of two matrices.

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

Returns the difference of two matrices.

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

Returns dot product of two matrices.

cpp
dMatrix3x3& operator*=(const dMatrix3x3& rhs);

Assigns the dot product of two matrices to the current matrix.

cpp
dMatrix3x3& operator/=(const double m);

Divides all entries of the current matrix by the factor m.

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

Subtracts matrix rhs from the current matrix.

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

Adds matrix rhs to the current matrix.

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

Assigns the content of the matrix rhs to the current matrix.

cpp
dMatrix3x3 Hadamard_product(const dMatrix3x3& rhs) const;

Returns Hadamard (component-wise) product of two matrices.

cpp
double determinant(void) const;

Returns determinant of the current matrix.

cpp
double double_contract(const dMatrix3x3& rhs) const;

Returns double-contraction of two matrices.

cpp
double trace(void) const;

Returns the trace of the current matrix.

cpp
double max(void) const;

Returns maximum element of the matrix.

cpp
double min(void) const;

Returns minimum element of the matrix.

cpp
double p_norm(double p);

Returns p-norm of the current matrix with the given p.

cpp
double norm(double p);

Returns Frobenius norm of the current matrix.

Data manipulation methods

cpp
void set(double r00, double r01, double r02,
         double r10, double r11, double r12,
         double r20, double r21, double r22)

Sets matrix elements to the correspnding values.

cpp
void set_to_zero(void);

Sets all entries to zero.

cpp
void set_to_unity(void);

Sets diagonal elements to one and all off-diagonal entries to zero.

cpp
dMatrix3x3& invert();

Inverts current matrix.

cpp
dMatrix3x3 inverted() const;

Returns inverted copy of the current matrix.

cpp
dMatrix3x3& transpose();

Transposes current matrix.

cpp
dMatrix3x3 transposed() const;

Returns transposed copy of the current matrix.

cpp
dMatrix3x3& rotate(const dMatrix3x3& RotationMatrix);

Rotates current matrix using the specified RotationMatrix.

cpp
dMatrix3x3 rotated(const dMatrix3x3& RotationMatrix) const;

Returns rotated copy of the current matrix using the specified RotationMatrix.

cpp
dMatrix3x3& rotateU(const dMatrix3x3& RotationMatrix);

Performs left-side rotation of current matrix using the specified RotationMatrix.

cpp
dMatrix3x3 rotatedU(const dMatrix3x3& RotationMatrix) const;

Returns left-side rotated copy of the current matrix.

cpp
dMatrix3x3& symmetrize(void);

Symmetrizes current matrix.

cpp
dMatrix3x3 symmetrized(void);

Returns symmetrized copy of the current matrix.

cpp
dMatrix3x3& power_elements(double &n);

Rises all elements of the current matrix to power n.

cpp
dMatrix3x3 powered_elements(double &n) const;

Returns copy of the current matrix with all elements resized to power n.

cpp
dMatrix3x3 get_skew(void) const;

Return skew-symmetric copy of the current matrix.

Container properties

cpp
constexpr size_t sizeX(void) const;

Returns first (X)-dimension of the stored matrix.

cpp
constexpr size_t sizeY(void) const;

Returns second (Y)-dimension of the stored matrix.

MPI communication methods

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

Packs the content of the current dMatrix3x3 object into the MPI communication buffer.

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

Unpacks (reads) the content of the current dMatrix3x3 object from the MPI communication buffer. The existing data in the container is overwritten.

Read/write methods

cpp
std::string print(void) const;

Returns formatted string of the matrix values ready to print to the terminal.

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

Reads matrix content from the input stream.

cpp
void write_ASCII(std::ostream& outp, const int precision = 16, const char sep = ' ') const;

Writes matrix content in ASCII format with the specified precision using sep as entry separator into the output stream.

cpp
std::string get_output_string(const int precision = 16, const char sep = ' ') const;

Returns output string with matrix content in ASCII format with the specified precision using sep as entry separator.

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

Returns std::vector containing current matrix components.

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

Returns std::vector<float> containing current matrix components rounded to float precision.

Released under the GNU GPLv3 License.