36 const int cMaxSweeps = 50;
54 for (
uint ip = 0; ip < n; ++ip)
60 outEigVal[ip] = a(ip, ip);
66 for (
int sweep = 0; sweep < cMaxSweeps; ++sweep)
70 for (
uint ip = 0; ip < n - 1; ++ip)
71 for (
uint iq = ip + 1; iq < n; ++iq)
73 float avg_sm = sm /
Square(n);
79 #ifdef JPH_ENABLE_ASSERTS
80 for (
uint c = 0; c < n; ++c)
98 float thresh = sweep < 4? 0.2f * avg_sm : FLT_MIN;
100 for (
uint ip = 0; ip < n - 1; ++ip)
101 for (
uint iq = ip + 1; iq < n; ++iq)
103 float &a_pq = a(ip, iq);
104 float &eigval_p = outEigVal[ip];
105 float &eigval_q = outEigVal[iq];
107 float abs_a_pq = abs(a_pq);
108 float g = 100.0f * abs_a_pq;
112 && abs(eigval_p) + g == abs(eigval_p)
113 && abs(eigval_q) + g == abs(eigval_q))
117 else if (abs_a_pq > thresh)
119 float h = eigval_q - eigval_p;
120 float abs_h = abs(h);
123 if (abs_h + g == abs_h)
129 float theta = 0.5f * h / a_pq;
130 t = 1.0f / (abs(theta) + sqrt(1.0f + theta * theta));
131 if (theta < 0.0f) t = -t;
134 float c = 1.0f / sqrt(1.0f + t * t);
136 float tau = s / (1.0f + c);
147 #define JPH_EVS_ROTATE(a, i, j, k, l) \
150 a(i, j) = g - s * (h + g * tau), \
151 a(k, l) = h + s * (g - h * tau)
159 #undef JPH_EVS_ROTATE
164 for (
uint ip = 0; ip < n; ++ip)
167 outEigVal[ip] = b[ip];
JPH_NAMESPACE_BEGIN bool EigenValueSymmetric(const Matrix &inMatrix, Matrix &outEigVec, Vector &outEigVal)
Definition EigenValueSymmetric.h:29