ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
matrix3.h
Go to the documentation of this file.
1#ifndef MatriX3_H
2#define MatriX3_H
3
4#include "matrix.h"
5#include "vector3.h"
6
7namespace ModuleBase
8{
9
15{
16
17 public:
22 double e11, e12, e13, e21, e22, e23, e31, e32, e33;
23
30 {
31 Identity();
32 }
33
47 Matrix3(const double &r11,
48 const double &r12,
49 const double &r13,
50 const double &r21,
51 const double &r22,
52 const double &r23,
53 const double &r31,
54 const double &r32,
55 const double &r33);
56
61 void Identity(void);
62
67 void Zero(void);
68
74 double Det(void) const;
75
81 Matrix3 Transpose(void) const;
82
88 Matrix3 Inverse(void) const;
89
97 Matrix3 &operator=(const Matrix3 &m);
98
106 Matrix3 &operator+=(const Matrix3 &m);
107
115 Matrix3 &operator-=(const Matrix3 &m);
116
125 Matrix3 &operator*=(const double &s);
126
135 Matrix3 &operator/=(const double &s);
136
141 void print(void) const;
142
149 ModuleBase::matrix to_matrix(void) const;
150};
151
160Matrix3 operator+(const Matrix3 &m1, const Matrix3 &m2);
161
170Matrix3 operator-(const Matrix3 &m1, const Matrix3 &m2);
171
180Matrix3 operator/(const Matrix3 &m, const double &s);
181
190Matrix3 operator*(const Matrix3 &m1, const Matrix3 &m2);
191
200Matrix3 operator*(const Matrix3 &m, const double &s);
201
210Matrix3 operator*(const double &s, const Matrix3 &m);
211
221template <typename T> ModuleBase::Vector3<double> operator*(const Matrix3 &m, const ModuleBase::Vector3<T> &u);
222
231template <typename T> ModuleBase::Vector3<double> operator*(const ModuleBase::Vector3<T> &u, const Matrix3 &m);
232
242bool operator==(const Matrix3 &m1, const Matrix3 &m2);
243
253bool operator!=(const Matrix3 &m1, const Matrix3 &m2); // whethor m1 != m2
254
255// m*u
257{
258 return ModuleBase::Vector3<double>(m.e11 * u.x + m.e12 * u.y + m.e13 * u.z,
259 m.e21 * u.x + m.e22 * u.y + m.e23 * u.z,
260 m.e31 * u.x + m.e32 * u.y + m.e33 * u.z);
261}
262
263// u*m
265{
266 return ModuleBase::Vector3<double>(u.x * m.e11 + u.y * m.e21 + u.z * m.e31,
267 u.x * m.e12 + u.y * m.e22 + u.z * m.e32,
268 u.x * m.e13 + u.y * m.e23 + u.z * m.e33);
269}
270
271} // namespace ModuleBase
272
273#endif // MATRIX3_H
3x3 matrix and related mathamatical operations
Definition matrix3.h:15
double e13
Definition matrix3.h:22
Matrix3 & operator-=(const Matrix3 &m)
Overload operator "-=" for 3x3 matrices For example, mb -= ma.
Definition matrix3.cpp:80
Matrix3 & operator=(const Matrix3 &m)
Overload operator "=" for 3x3 matrices For example, assign mb = ma.
Definition matrix3.cpp:64
Matrix3 & operator/=(const double &s)
Overload operator "/=" for 3x3 matrix and a scalar For example, mb /= 3.0.
Definition matrix3.cpp:96
Matrix3 Inverse(void) const
Inverse a 3x3 matrix.
Definition matrix3.cpp:44
double e31
Definition matrix3.h:22
void Identity(void)
Set a 3x3 matrix to identity matrix.
Definition matrix3.cpp:15
void Zero(void)
Set all elements of a 3x3 matrix to zero.
Definition matrix3.cpp:22
double e11
element e_ij: i_row, j_column
Definition matrix3.h:22
double e33
Definition matrix3.h:22
double e32
Definition matrix3.h:22
ModuleBase::matrix to_matrix(void) const
Change the form of a 3x3 matrix from that of class Matrix3 to that of class matrix.
Definition matrix3.cpp:203
double e21
Definition matrix3.h:22
double e12
Definition matrix3.h:22
double Det(void) const
Calculate the determinant of a 3x3 matrix.
Definition matrix3.cpp:29
Matrix3()
Construct a new Matrix 3 object to Identity matrix.
Definition matrix3.h:29
Matrix3 & operator*=(const double &s)
Overload operator "*=" for 3x3 matrix and a scalar For example, mb *= 3.0.
Definition matrix3.cpp:88
double e23
Definition matrix3.h:22
void print(void) const
Print a 3x3 matrix on screening.
Definition matrix3.cpp:195
double e22
Definition matrix3.h:22
Matrix3 & operator+=(const Matrix3 &m)
Overload operator "+=" for 3x3 matrices For example, mb += ma.
Definition matrix3.cpp:72
Matrix3 Transpose(void) const
Transpose a 3x3 matrix.
Definition matrix3.cpp:39
3 elements vector
Definition vector3.h:21
Definition matrix.h:15
Definition clebsch_gordan_coeff.cpp:8
ComplexMatrix operator-(const ComplexMatrix &m1, const ComplexMatrix &m2)
Definition complexmatrix.cpp:154
ComplexArray operator*(const double r, const ComplexArray &cd)
Scale a ComplexArray cd by real r.
Definition complexarray.cpp:173
bool operator!=(const Matrix3 &m1, const Matrix3 &m2)
Overload operator "!=" to assert the inequality between two 3x3 matrices.
Definition matrix3.cpp:189
Matrix3 operator/(const Matrix3 &m, const double &s)
Overload operator "/" for a (Matrix3)/(scalar) i.e. m/s.
Definition matrix3.cpp:133
bool operator==(const Matrix3 &m1, const Matrix3 &m2)
Overload operator "==" to assert the equality between two 3x3 matrices.
Definition matrix3.cpp:171
ComplexMatrix operator+(const ComplexMatrix &m1, const ComplexMatrix &m2)
Definition complexmatrix.cpp:143