1 #ifndef MONTJOIE_FILE_TINY_MATRIX_CXX
3 #include "TinyMatrix.hxx"
18 T one; SetComplexOne(one);
21 B(0,0) = A(1,1)*invDet;
22 B(1,0) = -A(1,0)*invDet;
23 B(0,1) = -A(0,1)*invDet;
24 B(1,1) = A(0,0)*invDet;
32 T one; SetComplexOne(one);
36 B(0,0) = B(1,1)*invDet;
48 T one; SetComplexOne(one);
51 B(0,0) = A(1,1)*invDet;
52 B(0,1) = -A(0,1)*invDet;
53 B(1,1) = A(0,0)*invDet;
61 T one; SetComplexOne(one);
65 B(0,0) = B(1,1)*invDet;
76 T trA = A(0, 0) + A(1, 1);
77 T delta = trA*trA - 4.0*(A(0,0)*A(1,1) - A(0,1)*A(1,0));
81 LambdaR(0) = 0.5*trA; LambdaR(1) = 0.5*trA;
82 LambdaI(0) = 0.5*delta; LambdaI(1) = -0.5*delta;
87 LambdaR(0) = 0.5*(trA - delta);
88 LambdaR(1) = 0.5*(trA + delta);
89 LambdaI(0) = 0; LambdaI(1) = 0;
99 complex<T> trA = A(0, 0) + A(1, 1);
100 complex<T> delta = trA - 4.0*(A(0,0)*A(1,1) - A(0,1)*A(1,0));
102 Lambda(0) = 0.5*(trA - delta);
103 Lambda(1) = 0.5*(trA + delta);
111 T a = A(0,0); T b = A(1,1); T c = A(1,0);
113 T delta = sqrt((a-b)*(a-b) + 4.0*c*c);
115 T l1 = T(0.5)*(a+b-delta); T l2 = T(0.5)*(a+b+delta);
118 T root_l1 = sqrt(l1); T root_l2 = sqrt(l2);
121 l1 = 1.0/(root_l1 + root_l2); l2 = root_l1*root_l2;
122 A(0,0) = (a+l2)*l1; A(1,0) = c*l1; A(1,1) = (b+l2)*l1;
132 template<
class T,
class Prop>
135 T d = A(0,0)*(A(1,1)*A(2,2) - A(2,1)*A(1,2))
136 - A(0,1)*(A(1,0)*A(2,2) - A(2,0)*A(1,2))
137 + A(0,2)*(A(1,0)*A(2,1) - A(2,0)*A(1,1));
148 T one; SetComplexOne(one);
151 B(0,0) = (A(1,1)*A(2,2)-A(2,1)*A(1,2))*invDet;
152 B(0,1) = -(A(0,1)*A(2,2)-A(2,1)*A(0,2))*invDet;
153 B(0,2) = (A(0,1)*A(1,2)-A(1,1)*A(0,2))*invDet;
154 B(1,0) = -(A(1,0)*A(2,2)-A(2,0)*A(1,2))*invDet;
155 B(1,1) = (A(0,0)*A(2,2)-A(2,0)*A(0,2))*invDet;
156 B(1,2) = -(A(0,0)*A(1,2)-A(1,0)*A(0,2))*invDet;
157 B(2,0) = (A(1,0)*A(2,1)-A(2,0)*A(1,1))*invDet;
158 B(2,1) = -(A(0,0)*A(2,1)-A(2,0)*A(0,1))*invDet;
159 B(2,2) = (A(0,0)*A(1,1)-A(1,0)*A(0,1))*invDet;
177 T one; SetComplexOne(one);
180 B(0,0) = (A(1,1)*A(2,2)-A(2,1)*A(1,2))*invDet;
181 B(0,1) = -(A(0,1)*A(2,2)-A(2,1)*A(0,2))*invDet;
182 B(0,2) = (A(0,1)*A(1,2)-A(1,1)*A(0,2))*invDet;
183 B(1,1) = (A(0,0)*A(2,2)-A(2,0)*A(0,2))*invDet;
184 B(1,2) = -(A(0,0)*A(1,2)-A(1,0)*A(0,2))*invDet;
185 B(2,2) = (A(0,0)*A(1,1)-A(1,0)*A(0,1))*invDet;
200 template<
class T0,
class T1>
204 P(0, 0) = n(1)*n(1) + n(2)*n(2);
205 P(0, 1) = -n(0)*n(1);
206 P(0, 2) = -n(0)*n(2);
207 P(1, 1) = n(0)*n(0) + n(2)*n(2);
208 P(1, 2) = -n(1)*n(2);
209 P(2, 2) = n(0)*n(0) + n(1)*n(1);
215 template<
class T0,
class T1>
230 template<
class T0,
class T1>
252 template<
class T,
class Property,
int m,
int n>
253 typename ClassComplexType<T>::Treal
255 int first_row,
int index_col)
257 typename ClassComplexType<T>::Treal sum(0);
258 for (
int i = first_row; i < m; i++)
267 template<
class T,
class Property,
class Storage,
class Allocator>
268 typename ClassComplexType<T>::Treal
270 int first_row,
int index_col)
272 typename ClassComplexType<T>::Treal sum(0);
273 for (
int i = first_row; i < A.GetM(); i++)
289 template<
class T,
int m>
297 T one; SetComplexOne(one);
298 T coef = one/A(m-1, m-1);
311 template<
class T,
int m>
326 template<
class T,
int m>
337 template<
class T,
int m>
352 template<
class T,
int m>
360 template<
class T,
class T2,
int m>
370 template<
class T,
class T2,
int m>
380 template<
class T,
class T2,
int m>
390 template<
class T,
class T2,
int m>
405 template<
int m,
class T>
413 for (
int i = 0; i < m; i++)
414 for (
int j = i; j < m; j++)
417 GetEigenvaluesEigenvectors(A2, w2, z2);
419 for (
int i = 0; i < m; i++)
423 for (
int j = 0; j < m; j++)
430 template<
int m,
class T>
436 for (
int i = 0; i < m; i++)
437 for (
int j = i; j < m; j++)
440 GetEigenvalues(A2, w2);
442 for (
int i = 0; i < m; i++)
448 template<
class T,
int m>
453 GetEigenvaluesEigenvectors(A, w, z);
458 for (
int i = 0; i < m; i++)
461 for (
int j = 0; j < m; j++)
470 #define MONTJOIE_FILE_TINY_MATRIX_CXX