Go to the source code of this file.
◆ REPORT
◆ WANT_MATH
◆ Jacobi() [1/4]
Definition at line 27 of file jacobi.cpp.
30 Real epsilon = FloatingPointPrecision::Epsilon();
35 B <<
A; D = B; Z = 0.0;
A.Inject(Z);
36 bool converged =
false;
37 for (
int i=1; i<=50; i++)
39 Real sm=0.0;
Real* a =
A.Store();
int p =
A.Storage();
40 while (p--) sm += fabs(*a++);
41 if (sm==0.0) {
REPORT converged =
true;
break; }
42 Real tresh = (i<4) ? 0.2 * sm /
square(
n) : 0.0; a =
A.Store();
43 for (p = 0; p <
n; p++)
45 Real* ap1 = a + (p*(p+1))/2;
47 for (
int q = p+1; q <
n; q++)
49 Real* ap = ap1;
Real* aq = a + (q*(q+1))/2;
51 Real& apq =
A.element(q,p);
52 Real g = 100 * fabs(apq);
Real adp = fabs(dp);
Real adq = fabs(dq);
54 if (i>4 && g < epsilon*adp && g < epsilon*adq) {
REPORT apq = 0.0; }
55 else if (fabs(apq) > tresh)
59 if (g < epsilon*ah) {
REPORT t = apq / h; }
63 Real theta = 0.5 * h / apq;
64 t = 1.0 / ( fabs(theta) + sqrt(1.0 +
square(theta)) );
65 if (theta<0.0) {
REPORT t = -t; }
68 Real tau = s / (1.0 + c); h = t * apq;
69 zp -= h; zq += h; dp -= h; dq += h; apq = 0.0;
74 *ap++ = g-s*(h+g*tau); *aq++ = h+s*(g-h*tau);
76 int ip = p+1; j = q-ip; ap += ip++; aq++;
80 *ap = g-s*(h+g*tau); *aq++ = h+s*(g-h*tau);
85 int iq = q+1; j =
n-iq; ap += ip++; aq += iq++;
89 *ap = g-s*(h+g*tau); *aq = h+s*(g-h*tau);
91 ap += ip++; aq += iq++;
103 B = B + Z; D = B; Z = 0.0;
106 if (eivec)
SortSV(D, V,
true);
void SortAscending(GeneralMatrix &)
void Rotate(RectMatrixCol &U, RectMatrixCol &V, Real tau, Real s)
virtual void ReSize(int, int)
os2<< "> n<< " > nendobj n
void SortSV(DiagonalMatrix &D, Matrix &U, bool ascending=false)
◆ Jacobi() [2/4]
Definition at line 110 of file jacobi.cpp.
void Jacobi(const SymmetricMatrix &X, DiagonalMatrix &D, SymmetricMatrix &A, Matrix &V, bool eivec)
◆ Jacobi() [3/4]
Definition at line 113 of file jacobi.cpp.
void Jacobi(const SymmetricMatrix &X, DiagonalMatrix &D, SymmetricMatrix &A, Matrix &V, bool eivec)
◆ Jacobi() [4/4]
Definition at line 116 of file jacobi.cpp.
void Jacobi(const SymmetricMatrix &X, DiagonalMatrix &D, SymmetricMatrix &A, Matrix &V, bool eivec)