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#ifdef _MCD_CHECK
5#include "mcd.h"
6#endif
7
8#include "matrix.h"
9#include "vector3.h"
10
11namespace ModuleBase
12{
13
19{
20
21 public:
26 double e11, e12, e13, e21, e22, e23, e31, e32, e33;
27
34 {
35 Identity();
36 }
37
51 Matrix3(const double &r11,
52 const double &r12,
53 const double &r13,
54 const double &r21,
55 const double &r22,
56 const double &r23,
57 const double &r31,
58 const double &r32,
59 const double &r33);
60
65 void Identity(void);
66
71 void Zero(void);
72
78 double Det(void) const;
79
85 Matrix3 Transpose(void) const;
86
92 Matrix3 Inverse(void) const;
93
101 Matrix3 &operator=(const Matrix3 &m);
102
110 Matrix3 &operator+=(const Matrix3 &m);
111
119 Matrix3 &operator-=(const Matrix3 &m);
120
129 Matrix3 &operator*=(const double &s);
130
139 Matrix3 &operator/=(const double &s);
140
145 void print(void) const;
146
153 ModuleBase::matrix to_matrix(void) const;
154};
155
164Matrix3 operator+(const Matrix3 &m1, const Matrix3 &m2);
165
174Matrix3 operator-(const Matrix3 &m1, const Matrix3 &m2);
175
184Matrix3 operator/(const Matrix3 &m, const double &s);
185
194Matrix3 operator*(const Matrix3 &m1, const Matrix3 &m2);
195
204Matrix3 operator*(const Matrix3 &m, const double &s);
205
214Matrix3 operator*(const double &s, const Matrix3 &m);
215
225template <typename T> ModuleBase::Vector3<double> operator*(const Matrix3 &m, const ModuleBase::Vector3<T> &u);
226
235template <typename T> ModuleBase::Vector3<double> operator*(const ModuleBase::Vector3<T> &u, const Matrix3 &m);
236
246bool operator==(const Matrix3 &m1, const Matrix3 &m2);
247
257bool operator!=(const Matrix3 &m1, const Matrix3 &m2); // whethor m1 != m2
258
259// m*u
261{
262 return ModuleBase::Vector3<double>(m.e11 * u.x + m.e12 * u.y + m.e13 * u.z,
263 m.e21 * u.x + m.e22 * u.y + m.e23 * u.z,
264 m.e31 * u.x + m.e32 * u.y + m.e33 * u.z);
265}
266
267// u*m
269{
270 return ModuleBase::Vector3<double>(u.x * m.e11 + u.y * m.e21 + u.z * m.e31,
271 u.x * m.e12 + u.y * m.e22 + u.z * m.e32,
272 u.x * m.e13 + u.y * m.e23 + u.z * m.e33);
273}
274
275} // namespace ModuleBase
276
277#endif // MATRIX3_H
3x3 matrix and related mathamatical operations
Definition matrix3.h:19
double e13
Definition matrix3.h:26
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:26
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:26
double e33
Definition matrix3.h:26
double e32
Definition matrix3.h:26
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:26
double e12
Definition matrix3.h:26
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:33
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:26
void print(void) const
Print a 3x3 matrix on screening.
Definition matrix3.cpp:195
double e22
Definition matrix3.h:26
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:22
Definition matrix.h:19
Definition array_pool.h:6
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:120
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