//------------------------------------------------------------------------------
// Name: SolveCubicEquation(a*x^3 + b*x^2+ c*x + d = 0)
// Desc: Solve Equation thru Root Finding Formula
// http://en.wikipedia.org/wiki/Cubic_equation
//------------------------------------------------------------------------------
void SolveCubicEquation(const float &a,const float &b,const float &c, const float &d, float *fRoot, float *fRootI)
{
float q = (3*a*c - (b*b)) / (9*a*a);
float r = (9*a*b*c - 27*a*a*d - 2*b*b*b) / (54*a*a*a);
float s = powf((r+sqrtf(q*q*q + r*r)), 1/3);
float t = powf((r-sqrtf(q*q*q + r*r)), 1/3);
if(fRoot && fRootI)
{
fRoot[0] = (s+t) - b/(3*a);
fRoot[1] = -(s+t)/2 - b/(3*a);
fRootI[0] = sqrtf(3)*(s-t)/2; //Complex Number value
fRoot[2] = -(s+t)/2 - b/(3*a);
fRootI[1] = sqrtf(3)*(s-t)/2; //Complex Number value
}
}
//------------------------------------------------------------------------------
// Name: FindEigenValues
// f[0] f[1] f[2]
// f[3] f[4] f[5]
// f[6] f[7] f[8]
// Desc: Find Eigen Value of symmetric 3X3 matrix
//------------------------------------------------------------------------------
void FindEigenValues(const float *m, float **fE, float **fEI)
{
float a = -1;
float b = m[0]+m[1]+m[8];
float c = m[3]*m[1] - m[0]*m[1] - m[0]*m[8] - m[1]*m[8] + m[5]*m[7];
float d = m[0]*m[1]*m[8] - m[0]*m[5]*m[7] - m[1]*m[3]*m[8] + m[6]*m[5]*m[1] +
m[2]*m[3]*m[7] - m[6]*m[4]*m[2];
SolveCubicEquation(a,b,c,d,*fE, *fEI);
}
Here i got EigenValues as
fE[0], fE[1] + fEI[0], fE[1] + fEI[2]












