OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
Matrix3D.h
Go to the documentation of this file.
1#ifndef OPALX_Matrix3D_HH
2#define OPALX_Matrix3D_HH
3
4// ------------------------------------------------------------------------
5// $RCSfile: Matrix3D.h,v $
6// ------------------------------------------------------------------------
7// $Revision: 1.1.1.1 $
8// ------------------------------------------------------------------------
9// Copyright: see Copyright.readme
10// ------------------------------------------------------------------------
11//
12// Class: Matrix3D
13//
14// ------------------------------------------------------------------------
15// Class category: BeamlineGeometry
16// ------------------------------------------------------------------------
17//
18// $Date: 2000/03/27 09:32:34 $
19// $Author: fci $
20//
21// ------------------------------------------------------------------------
22
23class Vector3D;
24
25// Class Matrix3D
26// ------------------------------------------------------------------------
28// The copy constructor, destructor, and assignment operator generated
29// by the compiler perform the correct operation. For speed reasons they
30// are not implemented.
31
32class Matrix3D {
33public:
35 // Constructs identity.
36 Matrix3D();
37
39 // Use the three vectors (a,b,c) as column vectors.
40 Matrix3D(const Vector3D& a, const Vector3D& b, const Vector3D& c);
41
43 // Use the elements as matrix elements by rows.
45 double x11, double x12, double x13, double x21, double x22, double x23, double x31,
46 double x32, double x33);
47
48 bool operator==(const Matrix3D&) const;
49 bool operator!=(const Matrix3D&) const;
50
52 // Return reference to matrix element (i,k).
53 double& operator()(int i, int k);
54
56 // Return value of matrix element (i,k).
57 double operator()(int i, int k) const;
58
60 Matrix3D& operator+=(const Matrix3D& rhs);
61
63 Matrix3D& operator-=(const Matrix3D& rhs);
64
66 Matrix3D& operator*=(const Matrix3D& rhs);
67
69 Matrix3D& operator*=(double factor);
70
72 static Matrix3D Identity();
73
75 Matrix3D inverse() const;
76
78 // Return true, if [b]this[/b] is an identity matrix.
79 bool isIdentity() const;
80
82 Matrix3D transpose() const;
83
84private:
85 // matrix elements
86 double m[3][3];
87};
88
89// Global operators.
90// ------------------------------------------------------------------------
91
93Matrix3D operator+(const Matrix3D& lhs, const Matrix3D& rhs);
94
96Matrix3D operator-(const Matrix3D& lhs, const Matrix3D& rhs);
97
99Matrix3D operator*(const Matrix3D& lhs, const Matrix3D& rhs);
100
102Vector3D operator*(const Matrix3D& lhs, const Vector3D& rhs);
103
104// Inline functions.
105// ------------------------------------------------------------------------
106
108 m[0][0] = 1.0;
109 m[0][1] = 0.0;
110 m[0][2] = 0.0;
111 m[1][0] = 0.0;
112 m[1][1] = 1.0;
113 m[1][2] = 0.0;
114 m[2][0] = 0.0;
115 m[2][1] = 0.0;
116 m[2][2] = 1.0;
117}
118
119inline double& Matrix3D::operator()(int i, int k) { return m[i][k]; }
120
121inline double Matrix3D::operator()(int i, int k) const { return m[i][k]; }
122
123#endif // __Matrix3D_HH
Matrix3D operator*(const Matrix3D &lhs, const Matrix3D &rhs)
Multiply.
Definition Matrix3D.cpp:155
Matrix3D operator+(const Matrix3D &lhs, const Matrix3D &rhs)
Add.
Definition Matrix3D.cpp:145
Matrix3D operator-(const Matrix3D &lhs, const Matrix3D &rhs)
Subtract.
Definition Matrix3D.cpp:150
3-dimensional matrix.
Definition Matrix3D.h:32
Matrix3D transpose() const
Transpose.
Definition Matrix3D.cpp:133
Matrix3D & operator-=(const Matrix3D &rhs)
Subtract and assign.
Definition Matrix3D.cpp:78
Matrix3D & operator+=(const Matrix3D &rhs)
Add and assign.
Definition Matrix3D.cpp:65
bool isIdentity() const
Test for identity.
Definition Matrix3D.cpp:108
Matrix3D & operator*=(const Matrix3D &rhs)
Multiply and assign.
Definition Matrix3D.cpp:91
double & operator()(int i, int k)
Get element.
Definition Matrix3D.h:119
bool operator!=(const Matrix3D &) const
Definition Matrix3D.cpp:59
Matrix3D inverse() const
Inverse.
Definition Matrix3D.cpp:114
bool operator==(const Matrix3D &) const
Definition Matrix3D.cpp:53
double m[3][3]
Definition Matrix3D.h:86
static Matrix3D Identity()
Make identity.
Definition Matrix3D.cpp:106
Matrix3D()
Default constructor.
Definition Matrix3D.h:107
A 3-dimension vector.
Definition Vector3D.h:30