28template <
class Vector,
class Matrix>
32 FPFlushDenormals flush_denormals;
33 (void)flush_denormals;
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)
78 #ifdef JPH_ENABLE_ASSERTS
79 for (
uint c = 0; c < n; ++c)
96 float tresh = sweep < 4? 0.2f * sm /
Square(n) : 0.0f;
98 for (
uint ip = 0; ip < n - 1; ++ip)
99 for (
uint iq = ip + 1; iq < n; ++iq)
101 float g = 100.0f * abs(a(ip, iq));
105 && abs(outEigVal[ip]) + g == abs(outEigVal[ip])
106 && abs(outEigVal[iq]) + g == abs(outEigVal[iq]))
110 else if (abs(a(ip, iq)) > tresh)
112 float h = outEigVal[iq] - outEigVal[ip];
115 if (abs(h) + g == abs(h))
121 float theta = 0.5f * h / a(ip, iq);
122 t = 1.0f / (abs(theta) + sqrt(1.0f + theta * theta));
123 if (theta < 0.0f) t = -t;
126 float c = 1.0f / sqrt(1.0f + t * t);
128 float tau = s / (1.0f + c);
144 #define JPH_EVS_ROTATE(a, i, j, k, l) \
147 a(i, j) = g - s * (h + g * tau), \
148 a(k, l) = h + s * (g - h * tau)
156 #undef JPH_EVS_ROTATE
162 for (
uint ip = 0; ip < n; ++ip)
165 outEigVal[ip] = b[ip];
unsigned int uint
Definition: Core.h:439
#define JPH_NAMESPACE_END
Definition: Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
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
constexpr T Square(T inV)
Square a value.
Definition: Math.h:52
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:180