CPPLapack
 All Classes Files Functions Variables Friends Pages
Classes | Functions
dsymatrix_small.hpp File Reference

Go to the source code of this file.

Classes

class  dsymatrix_small< n >
 Samll Real Double-precision Symmetric Matrix Class. More...
 

Functions

double det (const dsymat2 &)
 
dsymat2 inv (const dsymat2 &)
 
dsymat2 rotate (const dsymat2 &, const double &)
 
double det (const dsymat3 &)
 
dsymat3 inv (const dsymat3 &)
 
dsymat3 rotate (const dsymat3 &, const dquater &)
 

Function Documentation

double det ( const dsymat2 &  A)
inline

calculate determinant

Definition at line 3 of file dsymatrix_small-specialized.hpp.

Referenced by inv().

4 {CPPL_VERBOSE_REPORT;
5  return A(0,0)*A(1,1) -A(1,0)*A(1,0);
6 }
dsymat2 inv ( const dsymat2 &  A)
inline

calculate inverse

Definition at line 10 of file dsymatrix_small-specialized.hpp.

References det().

11 {CPPL_VERBOSE_REPORT;
12  const double Adet( det(A) );
13  dsymat2 Ainv;
14  Ainv(0,0)= A(1,1)/Adet;
15  Ainv(1,0)=-A(1,0)/Adet; Ainv(1,1)= A(0,0)/Adet;
16  return Ainv;
17 }
double det(const dsymat2 &A)
dsymat2 rotate ( const dsymat2 &  m,
const double &  theta 
)
inline

rotate 2D matrix by rotational angle

Definition at line 21 of file dsymatrix_small-specialized.hpp.

22 {CPPL_VERBOSE_REPORT;
23  double c(std::cos(theta)), s(std::sin(theta));
24  double cc(c*c), cs(c*s), ss(s*s);
25  dsymat2 mat;
26  mat(0,0) =m(0,0)*cc -2.*m(1,0)*cs +m(1,1)*ss;
27  mat(1,0) =m(1,0)*cc +(m(0,0)-m(1,1))*cs -m(1,0)*ss;
28  mat(1,1) =m(1,1)*cc +2.*m(1,0)*cs +m(0,0)*ss;
29  return mat;
30 }
double det ( const dsymat3 &  A)
inline

calculate determinant

Definition at line 44 of file dsymatrix_small-specialized.hpp.

45 {CPPL_VERBOSE_REPORT;
46  return
47  +A(0,0)*A(1,1)*A(2,2) -A(0,0)*A(2,1)*A(2,1)
48  +A(1,0)*A(2,1)*A(2,0) -A(1,0)*A(1,0)*A(2,2)
49  +A(2,0)*A(1,0)*A(2,1) -A(2,0)*A(1,1)*A(2,0);
50 }
dsymat3 inv ( const dsymat3 &  A)
inline

calculate inverse

Definition at line 54 of file dsymatrix_small-specialized.hpp.

References det().

55 {CPPL_VERBOSE_REPORT;
56  const double Adet( det(A) );
57  dsymat3 Ainv;
58  Ainv(0,0) =(A(1,1)*A(2,2)-A(2,1)*A(2,1))/Adet;
59  Ainv(1,0) =(A(2,1)*A(2,0)-A(1,0)*A(2,2))/Adet;
60  Ainv(1,1) =(A(0,0)*A(2,2)-A(2,0)*A(2,0))/Adet;
61  Ainv(2,0) =(A(1,0)*A(2,1)-A(1,1)*A(2,0))/Adet;
62  Ainv(2,1) =(A(1,0)*A(2,0)-A(0,0)*A(2,1))/Adet;
63  Ainv(2,2) =(A(0,0)*A(1,1)-A(1,0)*A(1,0))/Adet;
64  return Ainv;
65 }
double det(const dsymat2 &A)
dsymat3 rotate ( const dsymat3 &  m,
const dquater &  q 
)
inline

rotate 3D matrix by quaternion

Definition at line 69 of file dsymatrix_small-specialized.hpp.

References i(), and q2m().

70 {CPPL_VERBOSE_REPORT;
71  dgemat3 R =q2m(q);
72  dgemat3 Rm =R*m;
73 
74  dsymat3 RmRT;//not dgemat3
75  RmRT.zero();
76  for(CPPL_INT i=0; i<3; i++){
77  for(CPPL_INT j=0; j<=i; j++){
78  for(CPPL_INT k=0; k<3; k++){
79  RmRT(i,j) +=Rm(i,k)*R(j,k);
80  }
81  }
82  }
83  return RmRT;
84 }
_dgematrix i(const _dgbmatrix &mat)
dgemat3 q2m(const dquater &q)