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
cppdMatrix3x3();Default constructor, sets matrix values to zero;
cppdMatrix3x3(const dMatrix3x3& rhs);Copy constructor, initializes the current matrix with a copy of
rhs.
cppdMatrix3x3(std::initializer_list<double> matinit);Constructor, initializes the current matrix using initializer list
matinit.
cppstatic dMatrix3x3 ZeroTensor(void);Constructs and returns zero-valued matrix.
cppstatic dMatrix3x3 UnitTensor(void);Constructs and returns diagonal unity matrix.
Access operators
cppdouble& 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.
cppdouble* data(void); const double* data(void) const;Returns (const) pointer to the first element of the vector.
Logic, arithmetic and matrix-vector operations
cppbool operator==(const dMatrix3x3& rhs);Boolean comparison operator. Returns true if element-wise difference of the two matrices is smaller than
DBL_EPSILON.
cppbool operator!=(const dMatrix3x3& rhs);Boolean comparison operator. Returns true if element-wise difference of the two matrices is greater than
DBL_EPSILON.
cppdMatrix3x3 operator*(const double m) const;Returns current matrix with all components multiplied by the factor
m.
cppdMatrix3x3 operator/(const double m) const;Returns current matrix with all components divided by the factor
m.
cppdMatrix3x3 operator*(const dMatrix3x3& rhs) const;Returns dot product of two matrices.
cppdMatrix3x3 operator+(const dMatrix3x3& rhs) const;Returns the sum of two matrices.
cppdMatrix3x3 operator-(const dMatrix3x3& rhs) const;Returns the difference of two matrices.
cppdMatrix3x3 operator*(const dMatrix3x3& rhs) const;Returns dot product of two matrices.
cppdMatrix3x3& operator*=(const dMatrix3x3& rhs);Assigns the dot product of two matrices to the current matrix.
cppdMatrix3x3& operator/=(const double m);Divides all entries of the current matrix by the factor
m.
cppdMatrix3x3& operator-=(const dMatrix3x3& rhs);Subtracts matrix
rhsfrom the current matrix.
cppdMatrix3x3& operator+=(const dMatrix3x3& rhs);Adds matrix
rhsto the current matrix.
cppdMatrix3x3& operator=(const dMatrix3x3& rhs);Assigns the content of the matrix
rhsto the current matrix.
cppdMatrix3x3 Hadamard_product(const dMatrix3x3& rhs) const;Returns Hadamard (component-wise) product of two matrices.
cppdouble determinant(void) const;Returns determinant of the current matrix.
cppdouble double_contract(const dMatrix3x3& rhs) const;Returns double-contraction of two matrices.
cppdouble trace(void) const;Returns the trace of the current matrix.
cppdouble max(void) const;Returns maximum element of the matrix.
cppdouble min(void) const;Returns minimum element of the matrix.
cppdouble p_norm(double p);Returns p-norm of the current matrix with the given
p.
cppdouble norm(double p);Returns Frobenius norm of the current matrix.
Data manipulation methods
cppvoid 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.
cppvoid set_to_zero(void);Sets all entries to zero.
cppvoid set_to_unity(void);Sets diagonal elements to one and all off-diagonal entries to zero.
cppdMatrix3x3& invert();Inverts current matrix.
cppdMatrix3x3 inverted() const;Returns inverted copy of the current matrix.
cppdMatrix3x3& transpose();Transposes current matrix.
cppdMatrix3x3 transposed() const;Returns transposed copy of the current matrix.
cppdMatrix3x3& rotate(const dMatrix3x3& RotationMatrix);Rotates current matrix using the specified
RotationMatrix.
cppdMatrix3x3 rotated(const dMatrix3x3& RotationMatrix) const;Returns rotated copy of the current matrix using the specified
RotationMatrix.
cppdMatrix3x3& rotateU(const dMatrix3x3& RotationMatrix);Performs left-side rotation of current matrix using the specified
RotationMatrix.
cppdMatrix3x3 rotatedU(const dMatrix3x3& RotationMatrix) const;Returns left-side rotated copy of the current matrix.
cppdMatrix3x3& symmetrize(void);Symmetrizes current matrix.
cppdMatrix3x3 symmetrized(void);Returns symmetrized copy of the current matrix.
cppdMatrix3x3& power_elements(double &n);Rises all elements of the current matrix to power
n.
cppdMatrix3x3 powered_elements(double &n) const;Returns copy of the current matrix with all elements resized to power
n.
cppdMatrix3x3 get_skew(void) const;Return skew-symmetric copy of the current matrix.
Container properties
cppconstexpr size_t sizeX(void) const;Returns first (X)-dimension of the stored matrix.
cppconstexpr size_t sizeY(void) const;Returns second (Y)-dimension of the stored matrix.
MPI communication methods
cppvoid pack(std::vector<double>& buffer);Packs the content of the current
dMatrix3x3object into the MPI communication buffer.
cppvoid unpack(std::vector<double>& buffer, size_t& it);Unpacks (reads) the content of the current
dMatrix3x3object from the MPI communication buffer. The existing data in the container is overwritten.
Read/write methods
cppstd::string print(void) const;Returns formatted string of the matrix values ready to print to the terminal.
cppvoid read_ASCII(std::istream& inp);Reads matrix content from the input stream.
cppvoid write_ASCII(std::ostream& outp, const int precision = 16, const char sep = ' ') const;Writes matrix content in ASCII format with the specified
precisionusingsepas entry separator into the output stream.
cppstd::string get_output_string(const int precision = 16, const char sep = ' ') const;Returns output string with matrix content in ASCII format with the specified
precisionusingsepas entry separator.
cppstd::vector<double> get_vector() const;Returns
std::vectorcontaining current matrix components.
cppstd::vector<float> get_vector_float() const;Returns
std::vector<float>containing current matrix components rounded tofloatprecision.