CPPLapack
 All Classes Files Functions Variables Friends
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.

{VERBOSE_REPORT;
  return A(0,0)*A(1,1) -A(1,0)*A(1,0);
}
dsymat2 inv ( const dsymat2 &  A) [inline]

calculate inverse

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

References det().

{VERBOSE_REPORT;
  const double Adet( det(A) );
  dsymat2 Ainv;
  Ainv(0,0)= A(1,1)/Adet;
  Ainv(1,0)=-A(1,0)/Adet;  Ainv(1,1)= A(0,0)/Adet;
  return Ainv;
}
dsymat2 rotate ( const dsymat2 &  m,
const double &  theta 
) [inline]

return 2x2 rotated tensor

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

{VERBOSE_REPORT;
  double c(cos(theta)), s(sin(theta));
  double cc(c*c), cs(c*s), ss(s*s);
  dsymat2 mat;
  mat(0,0) =m(0,0)*cc -2.*m(1,0)*cs       +m(1,1)*ss;
  mat(1,0) =m(1,0)*cc +(m(0,0)-m(1,1))*cs -m(1,0)*ss;
  mat(1,1) =m(1,1)*cc +2.*m(1,0)*cs       +m(0,0)*ss;
  return mat;
}
double det ( const dsymat3 &  A) [inline]

calculate determinant

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

{VERBOSE_REPORT;
  return
    +A(0,0)*A(1,1)*A(2,2) -A(0,0)*A(2,1)*A(2,1)
    +A(1,0)*A(2,1)*A(2,0) -A(1,0)*A(1,0)*A(2,2)
    +A(2,0)*A(1,0)*A(2,1) -A(2,0)*A(1,1)*A(2,0);
}
dsymat3 inv ( const dsymat3 &  A) [inline]

calculate inverse

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

References det().

{VERBOSE_REPORT;
  const double Adet( det(A) );
  dsymat3 Ainv;
  Ainv(0,0) =(A(1,1)*A(2,2)-A(2,1)*A(2,1))/Adet;
  Ainv(1,0) =(A(2,1)*A(2,0)-A(1,0)*A(2,2))/Adet;
  Ainv(1,1) =(A(0,0)*A(2,2)-A(2,0)*A(2,0))/Adet;
  Ainv(2,0) =(A(1,0)*A(2,1)-A(1,1)*A(2,0))/Adet;
  Ainv(2,1) =(A(1,0)*A(2,0)-A(0,0)*A(2,1))/Adet;
  Ainv(2,2) =(A(0,0)*A(1,1)-A(1,0)*A(1,0))/Adet;
  return Ainv;
}
dsymat3 rotate ( const dsymat3 &  m,
const dquater &  q 
) [inline]

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

References i(), and q2m().

{VERBOSE_REPORT;
  dgemat3 R =q2m(q);
  dgemat3 Rm =R*m;
  
  dsymat3 RmRT;//not dgemat3
  RmRT.zero();
  for(long i=0; i<3; i++){
    for(long j=0; j<=i; j++){
      for(long k=0; k<3; k++){
        RmRT(i,j) +=Rm(i,k)*R(j,k);
      }
    }
  }
  return RmRT;
}
 All Classes Files Functions Variables Friends