Menu

[r120]: / trunk / include / small / dsymat2-function.hpp  Maximize  Restore  History

Download this file

31 lines (28 with data), 921 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//=============================================================================
/*! calculate determinant */
inline double det(const dsymat2& A)
{
return A(0,0)*A(1,1) -A(1,0)*A(1,0);
}
//=============================================================================
/*! calculate inverse */
inline dsymat2 inv(const dsymat2& A)
{
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;
}
//=============================================================================
/*! return 2x2 rotated tensor */
inline dsymat2 rotate(const dsymat2& m, const double& theta)
{
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;
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.