OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Matrix3D.h
Go to the documentation of this file.
1 #ifndef CLASSIC_Matrix3D_HH
2 #define CLASSIC_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 
23 class Vector3D;
24 
25 
26 // Class Matrix3D
27 // ------------------------------------------------------------------------
29 // The copy constructor, destructor, and assignment operator generated
30 // by the compiler perform the correct operation. For speed reasons they
31 // are not implemented.
32 
33 class Matrix3D {
34 
35 public:
36 
38  // Constructs identity.
39  Matrix3D();
40 
42  // Use the three vectors (a,b,c) as column vectors.
43  Matrix3D(const Vector3D &a, const Vector3D &b, const Vector3D &c);
44 
46  // Use the elements as matrix elements by rows.
47  Matrix3D(double x11, double x12, double x13,
48  double x21, double x22, double x23,
49  double x31, double x32, double x33);
50 
51  bool operator==(const Matrix3D &) const;
52  bool operator!=(const Matrix3D &) const;
53 
55  // Return reference to matrix element (i,k).
56  double &operator()(int i, int k) ;
57 
59  // Return value of matrix element (i,k).
60  double operator()(int i, int k) const;
61 
63  Matrix3D &operator+=(const Matrix3D &rhs);
64 
66  Matrix3D &operator-=(const Matrix3D &rhs);
67 
69  Matrix3D &operator*=(const Matrix3D &rhs);
70 
72  Matrix3D &operator*=(double factor) ;
73 
75  static Matrix3D Identity();
76 
78  Matrix3D inverse() const;
79 
81  // Return true, if [b]this[/b] is an identity matrix.
82  bool isIdentity() const;
83 
85  Matrix3D transpose() const;
86 
87 private:
88 
89  // matrix elements
90  double m[3][3];
91 };
92 
93 
94 // Global operators.
95 // ------------------------------------------------------------------------
96 
98 Matrix3D operator+(const Matrix3D &lhs, const Matrix3D &rhs);
99 
101 Matrix3D operator-(const Matrix3D &lhs, const Matrix3D &rhs);
102 
104 Matrix3D operator*(const Matrix3D &lhs, const Matrix3D &rhs);
105 
107 Vector3D operator*(const Matrix3D &lhs, const Vector3D &rhs);
108 
109 
110 // Inline functions.
111 // ------------------------------------------------------------------------
112 
114  m[0][0] = 1.0;
115  m[0][1] = 0.0;
116  m[0][2] = 0.0;
117  m[1][0] = 0.0;
118  m[1][1] = 1.0;
119  m[1][2] = 0.0;
120  m[2][0] = 0.0;
121  m[2][1] = 0.0;
122  m[2][2] = 1.0;
123 }
124 
125 
126 inline double &Matrix3D::operator()(int i, int k)
127 { return m[i][k]; }
128 
129 
130 inline double Matrix3D::operator()(int i, int k) const
131 { return m[i][k]; }
132 
133 #endif // __Matrix3D_HH
Matrix3D & operator-=(const Matrix3D &rhs)
Subtract and assign.
Definition: Matrix3D.cpp:84
Matrix< T > operator+(const Matrix< T > &, const Matrix< T > &)
Matrix addition.
Definition: Matrix.h:275
Matrix3D & operator+=(const Matrix3D &rhs)
Add and assign.
Definition: Matrix3D.cpp:70
Matrix3D transpose() const
Transpose.
Definition: Matrix3D.cpp:149
Matrix3D()
Default constructor.
Definition: Matrix3D.h:113
Matrix< T > operator*(const Matrix< T > &, const Matrix< T > &)
Matrix multiply.
Definition: Matrix.h:297
static Matrix3D Identity()
Make identity.
Definition: Matrix3D.cpp:117
Matrix3D & operator*=(const Matrix3D &rhs)
Multiply and assign.
Definition: Matrix3D.cpp:98
bool operator!=(const Matrix3D &) const
Definition: Matrix3D.cpp:63
bool isIdentity() const
Test for identity.
Definition: Matrix3D.cpp:122
double m[3][3]
Definition: Matrix3D.h:90
constexpr double c
The velocity of light in m/s.
Definition: Physics.h:52
3-dimensional matrix.
Definition: Matrix3D.h:33
double & operator()(int i, int k)
Get element.
Definition: Matrix3D.h:126
A 3-dimension vector.
Definition: Vector3D.h:31
Matrix3D inverse() const
Inverse.
Definition: Matrix3D.cpp:129
bool operator==(const Matrix3D &) const
Definition: Matrix3D.cpp:56
Matrix< T > operator-(const Matrix< T > &, const Matrix< T > &)
Matrix subtraction.
Definition: Matrix.h:282