28template <
class Vector,
class Matrix>
33 (void)disable_invalid;
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 tresh = 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 > tresh)
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];
unsigned int uint
Definition: Core.h:452
#define JPH_NAMESPACE_END
Definition: Core.h:378
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:372
JPH_NAMESPACE_BEGIN bool EigenValueSymmetric(const Matrix &inMatrix, Matrix &outEigVec, Vector &outEigVal)
Definition: EigenValueSymmetric.h:29
#define JPH_EVS_ROTATE(a, i, j, k, l)
#define JPH_ASSERT(...)
Definition: IssueReporting.h:33
JPH_INLINE constexpr T Square(T inV)
Square a value.
Definition: Math.h:52
Definition: FPException.h:69
Templatized matrix class.
Definition: Matrix.h:15
uint GetRows() const
Dimensions.
Definition: Matrix.h:22
bool IsIdentity() const
Check if this matrix is identity.
Definition: Matrix.h:58
uint GetCols() const
Definition: Matrix.h:23
const Vector< Rows > & GetColumn(int inIdx) const
Column access.
Definition: Matrix.h:225
Templatized vector class.
Definition: Vector.h:12
uint GetRows() const
Dimensions.
Definition: Vector.h:19
bool IsClose(const Vector &inV2, float inMaxDistSq=1.0e-12f)
Test if two vectors are close to each other.
Definition: Vector.h:78
float LengthSq() const
Squared length of vector.
Definition: Vector.h:175