SheafSystem  0.0.0.0
symmetric_matrix_3x3.h
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
18 // Interface for symmetric_matrix_3x3 classes.
19 
20 #ifndef SYMMETRIC_MATRIX_3X3_H
21 #define SYMMETRIC_MATRIX_3X3_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifndef STD_IOSTREAM_H
28 #include "SheafSystem/std_iostream.h"
29 #endif
30 
31 namespace fiber_bundle
32 {
33 
34 template <typename T> class general_matrix_1x3;
35 template <typename T> class general_matrix_3x1;
36 template <typename T> class general_matrix_3x2;
37 template <typename T> class general_matrix_3x3;
38 
39 template <typename T> class met_e3_row_dofs_type;
40 template <typename T> class st2_e3_row_dofs_type;
41 
42 //==============================================================================
43 //==============================================================================
44 
55 template <typename T>
56 class symmetric_matrix_3x3
57 {
58 public:
59 
63  operator met_e3_row_dofs_type<T>& () const;
64 
68  operator st2_e3_row_dofs_type<T>& () const;
69 
73  static int number_of_rows();
74 
78  static int number_of_columns();
79 
83  static int d();
84 
89  T* operator[](int xrow);
90 
95  const T* operator[](int xrow) const;
96 
101  operator T* ();
102 
107  operator const T* () const;
108 
112  int row_index(int xrow) const;
113 
117  operator general_matrix_3x3<T> () const;
118 
122  general_matrix_1x3<T> row(int xrow) const;
123 
127  general_matrix_3x1<T> column(int xcolumn) const;
128 
133 
134  //============================================================================
135  //============================================================================
136 
140  void adjoint(symmetric_matrix_3x3<T>& xresult) const;
141 
146 
150  void assign(const T& xscalar);
151 
155  void determinant(T& xresult) const;
156 
160  T determinant() const;
161 
165  void diagonalization(symmetric_matrix_3x3<T>& xresult) const;
166 
171 
175  void identity(symmetric_matrix_3x3<T>& xresult) const;
176 
181 
185  void inverse(symmetric_matrix_3x3<T>& xresult) const;
186 
191 
195  bool is_diagonal() const;
196 
200  bool is_identity() const;
201 
205  bool is_positive_definite() const;
206 
210  void multiply(const T& xscalar, symmetric_matrix_3x3<T>& xresult) const;
211 
215  symmetric_matrix_3x3<T> multiply(const T& xscalar) const;
216 
220  void multiply(const general_matrix_3x1<T>& xother,
221  general_matrix_3x1<T>& xresult) const;
222 
227 
231  void multiply(const general_matrix_3x2<T>& xother,
232  general_matrix_3x2<T>& xresult) const;
233 
238 
242  void multiply(const general_matrix_3x3<T>& xother,
243  general_matrix_3x3<T>& xresult) const;
244 
249 
255  void multiply(const symmetric_matrix_3x3<T>& xother,
256  general_matrix_3x3<T>& xresult) const;
257 
264 
268  void trace(T& xresult) const;
269 
273  T trace() const;
274 
278  void transpose(symmetric_matrix_3x3<T>& xresult) const;
279 
284 
291 
292 
293 protected:
294 private:
295 
296 };
297 
298 // =============================================================================
299 // NON-MEMBER FUNCTIONS
300 // =============================================================================
301 
305 template <typename T>
306 std::ostream& operator<<(std::ostream& xos, const symmetric_matrix_3x3<T>& xm);
307 
310 // using the cyclic Jacobi iteration method.
314 template <typename T>
316  general_matrix_3x3<T>& xeigenvectors,
317  T xeigenvalues[3]);
318 
321 // using the cyclic Jacobi iteration method.
325 template <typename T>
327  general_matrix_3x3<T>& xeigenvectors,
328  symmetric_matrix_3x3<T>& xdiagonal);
333 template <typename T>
334 void sort_eigenvalues(general_matrix_3x3<T>& xeigenvectors,
335  T xeigenvalues[3]);
336 
337 } // namespace fiber_bundle
338 
339 #endif // ifndef SYMMETRIC_MATRIX_3X3_H
void jacobi_transformation(const symmetric_matrix_3x3< T > &xm, general_matrix_3x3< T > &xeigenvectors, T xeigenvalues[3])
Determine the eigenvectors and eigenvalues of a real symmetric matrix xm.
bool is_identity() const
True if this is an identity matrix.
T trace() const
The trace of the matrix (auto-allocated).
static int d()
Dimension of the underlying elements.
General matrix with 3 rows and 2 columns.
static int number_of_rows()
The number of rows.
void sort_eigenvalues(general_matrix_3x3< T > &xeigenvectors, T xeigenvalues[3])
Utility function to sort the eigenvalues into ascending order. Called from jacobi_transformation.
void assign(const T &xscalar)
Assign all elements of this matrix to the value xvalue.
int row_index(int xrow) const
Index for row xrow in the linear storage array.
T * operator[](int xrow)
Pointer to the first element in row xrow of this matrix. Facilitates accessing elements via matrix[i]...
general_matrix_3x1< T > column(int xcolumn) const
A 3x1 matrix containing the elements or column xcolumn.
symmetric_matrix_3x3< T > identity() const
The identity matrix (auto-allocated).
General matrix with 3 rows and 1 column.
T components[6]
Linear storage array.
bool is_positive_definite() const
True if this matrix is positive definite.
symmetric_matrix_3x3< T > inverse() const
The inverse of the matrix (auto-allocated).
symmetric_matrix_3x3< T > adjoint() const
The adjoint of the matrix (auto-allocated).
symmetric_matrix_3x3< T > transpose() const
The transpose of the matrix (auto-allocated).
bool is_diagonal() const
True if this matrix is diagonal.
static int number_of_columns()
The number of columns.
General matrix with 3 rows and 3 columns.
general_matrix_1x3< T > row(int xrow) const
A 1x3 matrix containing the elements or row xrow.
void multiply(const T &xscalar, symmetric_matrix_3x3< T > &xresult) const
This matrix multiplied by a scalar (pre-allocated).
T determinant() const
The determinant of the matrix (auto-allocated).
Namespace for the fiber_bundles component of the sheaf system.
symmetric_matrix_3x3< T > diagonalization() const
The diagonalization of the matrix (auto-allocated).
Symmetric matrix with 3 rows and 3 columns.