Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

gmtl::Eigen Class Reference

#include <Eigen.h>

List of all members.

Public Methods

 Eigen (int iSize)
 ~Eigen ()
float & Matrix (int iRow, int iCol)
void SetMatrix (float **aafMat)
float GetEigenvalue (int i) const
float GetEigenvector (int iRow, int iCol) const
float * GetEigenvalue ()
float ** GetEigenvector ()
void EigenStuff2 ()
void EigenStuff3 ()
void EigenStuff4 ()
void EigenStuffN ()
void EigenStuff ()
void DecrSortEigenStuff2 ()
void DecrSortEigenStuff3 ()
void DecrSortEigenStuff4 ()
void DecrSortEigenStuffN ()
void DecrSortEigenStuff ()
void IncrSortEigenStuff2 ()
void IncrSortEigenStuff3 ()
void IncrSortEigenStuff4 ()
void IncrSortEigenStuffN ()
void IncrSortEigenStuff ()

Static Protected Methods

void Tridiagonal2 (float **aafMat, float *afDiag, float *afSubd)
void Tridiagonal3 (float **aafMat, float *afDiag, float *afSubd)
void Tridiagonal4 (float **aafMat, float *afDiag, float *afSubd)
void TridiagonalN (int iSize, float **aafMat, float *afDiag, float *afSubd)
bool QLAlgorithm (int iSize, float *afDiag, float *afSubd, float **aafMat)
void DecreasingSort (int iSize, float *afEigval, float **aafEigvec)
void IncreasingSort (int iSize, float *afEigval, float **aafEigvec)

Protected Attributes

int m_iSize
float ** m_aafMat
float * m_afDiag
float * m_afSubd


Constructor & Destructor Documentation

gmtl::Eigen::Eigen int    iSize
 

Definition at line 144 of file Eigen.h.

References m_aafMat, m_afDiag, m_afSubd, and m_iSize.

00145 {
00146     assert( iSize >= 2 );
00147     m_iSize = iSize;
00148 
00149     m_aafMat = new float*[m_iSize];
00150     for (int i = 0; i < m_iSize; i++)
00151         m_aafMat[i] = new float[m_iSize];
00152 
00153     m_afDiag = new float[m_iSize];
00154     m_afSubd = new float[m_iSize];
00155 }

gmtl::Eigen::~Eigen  
 

Definition at line 157 of file Eigen.h.

References m_aafMat, m_afDiag, m_afSubd, and m_iSize.

00158 {
00159     delete[] m_afSubd;
00160     delete[] m_afDiag;
00161     for (int i = 0; i < m_iSize; i++)
00162         delete[] m_aafMat[i];
00163     delete[] m_aafMat;
00164 }


Member Function Documentation

void gmtl::Eigen::DecreasingSort int    iSize,
float *    afEigval,
float **    aafEigvec
[static, protected]
 

Definition at line 551 of file Eigen.h.

Referenced by DecrSortEigenStuff, DecrSortEigenStuff2, DecrSortEigenStuff3, DecrSortEigenStuff4, and DecrSortEigenStuffN.

00553 {
00554     // sort eigenvalues in decreasing order, e[0] >= ... >= e[iSize-1]
00555     for (int i0 = 0, i1; i0 <= iSize-2; i0++)
00556     {
00557         // locate maximum eigenvalue
00558         i1 = i0;
00559         float fMax = afEigval[i1];
00560         int i2;
00561         for (i2 = i0+1; i2 < iSize; i2++)
00562         {
00563             if ( afEigval[i2] > fMax )
00564             {
00565                 i1 = i2;
00566                 fMax = afEigval[i1];
00567             }
00568         }
00569 
00570         if ( i1 != i0 )
00571         {
00572             // swap eigenvalues
00573             afEigval[i1] = afEigval[i0];
00574             afEigval[i0] = fMax;
00575 
00576             // swap eigenvectors
00577             for (i2 = 0; i2 < iSize; i2++)
00578             {
00579                 float fTmp = aafEigvec[i2][i0];
00580                 aafEigvec[i2][i0] = aafEigvec[i2][i1];
00581                 aafEigvec[i2][i1] = fTmp;
00582             }
00583         }
00584     }
00585 }

void gmtl::Eigen::DecrSortEigenStuff  
 

Definition at line 704 of file Eigen.h.

References DecreasingSort, m_aafMat, m_afDiag, m_afSubd, m_iSize, QLAlgorithm, Tridiagonal2, Tridiagonal3, Tridiagonal4, and TridiagonalN.

00705 {
00706     switch ( m_iSize )
00707     {
00708         case 2:
00709             Tridiagonal2(m_aafMat,m_afDiag,m_afSubd);
00710             break;
00711         case 3:
00712             Tridiagonal3(m_aafMat,m_afDiag,m_afSubd);
00713             break;
00714         case 4:
00715             Tridiagonal4(m_aafMat,m_afDiag,m_afSubd);
00716             break;
00717         default:
00718             TridiagonalN(m_iSize,m_aafMat,m_afDiag,m_afSubd);
00719             break;
00720     }
00721     QLAlgorithm(m_iSize,m_afDiag,m_afSubd,m_aafMat);
00722     DecreasingSort(m_iSize,m_afDiag,m_aafMat);
00723 }

void gmtl::Eigen::DecrSortEigenStuff2  
 

Definition at line 676 of file Eigen.h.

References DecreasingSort, m_aafMat, m_afDiag, m_afSubd, m_iSize, QLAlgorithm, and Tridiagonal2.

void gmtl::Eigen::DecrSortEigenStuff3  
 

Definition at line 683 of file Eigen.h.

References DecreasingSort, m_aafMat, m_afDiag, m_afSubd, m_iSize, QLAlgorithm, and Tridiagonal3.

void gmtl::Eigen::DecrSortEigenStuff4  
 

Definition at line 690 of file Eigen.h.

References DecreasingSort, m_aafMat, m_afDiag, m_afSubd, m_iSize, QLAlgorithm, and Tridiagonal4.

void gmtl::Eigen::DecrSortEigenStuffN  
 

Definition at line 697 of file Eigen.h.

References DecreasingSort, m_aafMat, m_afDiag, m_afSubd, m_iSize, QLAlgorithm, and TridiagonalN.

void gmtl::Eigen::EigenStuff  
 

Definition at line 656 of file Eigen.h.

References m_aafMat, m_afDiag, m_afSubd, m_iSize, QLAlgorithm, Tridiagonal2, Tridiagonal3, Tridiagonal4, and TridiagonalN.

00657 {
00658     switch ( m_iSize )
00659     {
00660         case 2:
00661             Tridiagonal2(m_aafMat,m_afDiag,m_afSubd);
00662             break;
00663         case 3:
00664             Tridiagonal3(m_aafMat,m_afDiag,m_afSubd);
00665             break;
00666         case 4:
00667             Tridiagonal4(m_aafMat,m_afDiag,m_afSubd);
00668             break;
00669         default:
00670             TridiagonalN(m_iSize,m_aafMat,m_afDiag,m_afSubd);
00671             break;
00672     }
00673     QLAlgorithm(m_iSize,m_afDiag,m_afSubd,m_aafMat);
00674 }

void gmtl::Eigen::EigenStuff2  
 

Definition at line 632 of file Eigen.h.

References m_aafMat, m_afDiag, m_afSubd, m_iSize, QLAlgorithm, and Tridiagonal2.

void gmtl::Eigen::EigenStuff3  
 

Definition at line 638 of file Eigen.h.

References m_aafMat, m_afDiag, m_afSubd, m_iSize, QLAlgorithm, and Tridiagonal3.

void gmtl::Eigen::EigenStuff4  
 

Definition at line 644 of file Eigen.h.

References m_aafMat, m_afDiag, m_afSubd, m_iSize, QLAlgorithm, and Tridiagonal4.

void gmtl::Eigen::EigenStuffN  
 

Definition at line 650 of file Eigen.h.

References m_aafMat, m_afDiag, m_afSubd, m_iSize, QLAlgorithm, and TridiagonalN.

float * gmtl::Eigen::GetEigenvalue   [inline]
 

Definition at line 128 of file Eigen.h.

References m_afDiag.

00129 {
00130     return m_afDiag;
00131 }

float gmtl::Eigen::GetEigenvalue int    i const [inline]
 

Definition at line 118 of file Eigen.h.

References m_afDiag.

00119 {
00120     return m_afDiag[i];
00121 }

float ** gmtl::Eigen::GetEigenvector   [inline]
 

Definition at line 133 of file Eigen.h.

References m_aafMat.

00134 {
00135     return m_aafMat;
00136 }

float gmtl::Eigen::GetEigenvector int    iRow,
int    iCol
const [inline]
 

Definition at line 123 of file Eigen.h.

References m_aafMat.

00124 {
00125     return m_aafMat[iRow][iCol];
00126 }

void gmtl::Eigen::IncreasingSort int    iSize,
float *    afEigval,
float **    aafEigvec
[static, protected]
 

Definition at line 587 of file Eigen.h.

Referenced by IncrSortEigenStuff, IncrSortEigenStuff2, IncrSortEigenStuff3, IncrSortEigenStuff4, and IncrSortEigenStuffN.

00589 {
00590     // sort eigenvalues in increasing order, e[0] <= ... <= e[iSize-1]
00591     for (int i0 = 0, i1; i0 <= iSize-2; i0++)
00592     {
00593         // locate minimum eigenvalue
00594         i1 = i0;
00595         float fMin = afEigval[i1];
00596         int i2;
00597         for (i2 = i0+1; i2 < iSize; i2++)
00598         {
00599             if ( afEigval[i2] < fMin )
00600             {
00601                 i1 = i2;
00602                 fMin = afEigval[i1];
00603             }
00604         }
00605 
00606         if ( i1 != i0 )
00607         {
00608             // swap eigenvalues
00609             afEigval[i1] = afEigval[i0];
00610             afEigval[i0] = fMin;
00611 
00612             // swap eigenvectors
00613             for (i2 = 0; i2 < iSize; i2++)
00614             {
00615                 float fTmp = aafEigvec[i2][i0];
00616                 aafEigvec[i2][i0] = aafEigvec[i2][i1];
00617                 aafEigvec[i2][i1] = fTmp;
00618             }
00619         }
00620     }
00621 }

void gmtl::Eigen::IncrSortEigenStuff  
 

Definition at line 753 of file Eigen.h.

References IncreasingSort, m_aafMat, m_afDiag, m_afSubd, m_iSize, QLAlgorithm, Tridiagonal2, Tridiagonal3, Tridiagonal4, and TridiagonalN.

00754 {
00755     switch ( m_iSize )
00756     {
00757         case 2:
00758             Tridiagonal2(m_aafMat,m_afDiag,m_afSubd);
00759             break;
00760         case 3:
00761             Tridiagonal3(m_aafMat,m_afDiag,m_afSubd);
00762             break;
00763         case 4:
00764             Tridiagonal4(m_aafMat,m_afDiag,m_afSubd);
00765             break;
00766         default:
00767             TridiagonalN(m_iSize,m_aafMat,m_afDiag,m_afSubd);
00768             break;
00769     }
00770     QLAlgorithm(m_iSize,m_afDiag,m_afSubd,m_aafMat);
00771     IncreasingSort(m_iSize,m_afDiag,m_aafMat);
00772 }

void gmtl::Eigen::IncrSortEigenStuff2  
 

Definition at line 725 of file Eigen.h.

References IncreasingSort, m_aafMat, m_afDiag, m_afSubd, m_iSize, QLAlgorithm, and Tridiagonal2.

void gmtl::Eigen::IncrSortEigenStuff3  
 

Definition at line 732 of file Eigen.h.

References IncreasingSort, m_aafMat, m_afDiag, m_afSubd, m_iSize, QLAlgorithm, and Tridiagonal3.

void gmtl::Eigen::IncrSortEigenStuff4  
 

Definition at line 739 of file Eigen.h.

References IncreasingSort, m_aafMat, m_afDiag, m_afSubd, m_iSize, QLAlgorithm, and Tridiagonal4.

void gmtl::Eigen::IncrSortEigenStuffN  
 

Definition at line 746 of file Eigen.h.

References IncreasingSort, m_aafMat, m_afDiag, m_afSubd, m_iSize, QLAlgorithm, and TridiagonalN.

float & gmtl::Eigen::Matrix int    iRow,
int    iCol
[inline]
 

Definition at line 113 of file Eigen.h.

References m_aafMat.

00114 {
00115     return m_aafMat[iRow][iCol];
00116 }

bool gmtl::Eigen::QLAlgorithm int    iSize,
float *    afDiag,
float *    afSubd,
float **    aafMat
[static, protected]
 

Definition at line 479 of file Eigen.h.

References gmtl::Math::abs, m_aafMat, m_afDiag, m_afSubd, and gmtl::Math::sqrt.

Referenced by DecrSortEigenStuff, DecrSortEigenStuff2, DecrSortEigenStuff3, DecrSortEigenStuff4, DecrSortEigenStuffN, EigenStuff, EigenStuff2, EigenStuff3, EigenStuff4, EigenStuffN, IncrSortEigenStuff, IncrSortEigenStuff2, IncrSortEigenStuff3, IncrSortEigenStuff4, and IncrSortEigenStuffN.

00481 {
00482     const int iMaxIter = 32;
00483 
00484     for (int i0 = 0; i0 < iSize; i0++)
00485     {
00486         int i1;
00487         for (i1 = 0; i1 < iMaxIter; i1++)
00488         {
00489             int i2;
00490             for (i2 = i0; i2 <= iSize-2; i2++)
00491             {
00492                 float fTmp =
00493                     Math::abs(m_afDiag[i2])+ Math::abs(m_afDiag[i2+1]);
00494                 if ( Math::abs(m_afSubd[i2]) + fTmp == fTmp )
00495                     break;
00496             }
00497             if ( i2 == i0 )
00498                 break;
00499 
00500             float fG = (m_afDiag[i0+1]-m_afDiag[i0])/(2.0*m_afSubd[i0]);
00501             float fR = Math::sqrt(fG*fG+1.0);
00502             if ( fG < 0.0 )
00503                 fG = m_afDiag[i2]-m_afDiag[i0]+m_afSubd[i0]/(fG-fR);
00504             else
00505                 fG = m_afDiag[i2]-m_afDiag[i0]+m_afSubd[i0]/(fG+fR);
00506             float fSin = 1.0, fCos = 1.0, fP = 0.0;
00507             for (int i3 = i2-1; i3 >= i0; i3--)
00508             {
00509                 float fF = fSin*m_afSubd[i3];
00510                 float fB = fCos*m_afSubd[i3];
00511                 if ( Math::abs(fF) >= Math::abs(fG) )
00512                 {
00513                     fCos = fG/fF;
00514                     fR = sqrt(fCos*fCos+1.0);
00515                     m_afSubd[i3+1] = fF*fR;
00516                     fSin = 1.0/fR;
00517                     fCos *= fSin;
00518                 }
00519                 else
00520                 {
00521                     fSin = fF/fG;
00522                     fR = Math::sqrt(fSin*fSin+1.0);
00523                     m_afSubd[i3+1] = fG*fR;
00524                     fCos = 1.0/fR;
00525                     fSin *= fCos;
00526                 }
00527                 fG = m_afDiag[i3+1]-fP;
00528                 fR = (m_afDiag[i3]-fG)*fSin+2.0*fB*fCos;
00529                 fP = fSin*fR;
00530                 m_afDiag[i3+1] = fG+fP;
00531                 fG = fCos*fR-fB;
00532 
00533                 for (int i4 = 0; i4 < iSize; i4++)
00534                 {
00535                     fF = m_aafMat[i4][i3+1];
00536                     m_aafMat[i4][i3+1] = fSin*m_aafMat[i4][i3]+fCos*fF;
00537                     m_aafMat[i4][i3] = fCos*m_aafMat[i4][i3]-fSin*fF;
00538                 }
00539             }
00540             m_afDiag[i0] -= fP;
00541             m_afSubd[i0] = fG;
00542             m_afSubd[i2] = 0.0;
00543         }
00544         if ( i1 == iMaxIter )
00545             return false;
00546     }
00547 
00548     return true;
00549 }

void gmtl::Eigen::SetMatrix float **    aafMat
 

Definition at line 623 of file Eigen.h.

References m_aafMat, and m_iSize.

00624 {
00625     for (int iRow = 0; iRow < m_iSize; iRow++)
00626     {
00627         for (int iCol = 0; iCol < m_iSize; iCol++)
00628             m_aafMat[iRow][iCol] = aafMat[iRow][iCol];
00629     }
00630 }

void gmtl::Eigen::Tridiagonal2 float **    aafMat,
float *    afDiag,
float *    afSubd
[static, protected]
 

Definition at line 166 of file Eigen.h.

References m_aafMat, m_afDiag, and m_afSubd.

Referenced by DecrSortEigenStuff, DecrSortEigenStuff2, EigenStuff, EigenStuff2, IncrSortEigenStuff, and IncrSortEigenStuff2.

00168 {
00169     // matrix is already tridiagonal
00170     m_afDiag[0] = m_aafMat[0][0];
00171     m_afDiag[1] = m_aafMat[1][1];
00172     m_afSubd[0] = m_aafMat[0][1];
00173     m_afSubd[1] = 0.0;
00174     m_aafMat[0][0] = 1.0;
00175     m_aafMat[0][1] = 0.0;
00176     m_aafMat[1][0] = 0.0;
00177     m_aafMat[1][1] = 1.0;
00178 }

void gmtl::Eigen::Tridiagonal3 float **    aafMat,
float *    afDiag,
float *    afSubd
[static, protected]
 

Definition at line 180 of file Eigen.h.

References m_aafMat, m_afDiag, m_afSubd, and gmtl::Math::sqrt.

Referenced by DecrSortEigenStuff, DecrSortEigenStuff3, EigenStuff, EigenStuff3, IncrSortEigenStuff, and IncrSortEigenStuff3.

00182 {
00183     float fM00 = m_aafMat[0][0];
00184     float fM01 = m_aafMat[0][1];
00185     float fM02 = m_aafMat[0][2];
00186     float fM11 = m_aafMat[1][1];
00187     float fM12 = m_aafMat[1][2];
00188     float fM22 = m_aafMat[2][2];
00189 
00190     m_afDiag[0] = fM00;
00191     m_afSubd[2] = 0.0;
00192     if ( fM02 != 0.0 )
00193     {
00194         float fLength = Math::sqrt(fM01*fM01+fM02*fM02);
00195         float fInvLength = 1.0/fLength;
00196         fM01 *= fInvLength;
00197         fM02 *= fInvLength;
00198         float fQ = 2.0*fM01*fM12+fM02*(fM22-fM11);
00199         m_afDiag[1] = fM11+fM02*fQ;
00200         m_afDiag[2] = fM22-fM02*fQ;
00201         m_afSubd[0] = fLength;
00202         m_afSubd[1] = fM12-fM01*fQ;
00203         m_aafMat[0][0] = 1.0; m_aafMat[0][1] = 0.0;  m_aafMat[0][2] = 0.0;
00204         m_aafMat[1][0] = 0.0; m_aafMat[1][1] = fM01; m_aafMat[1][2] = fM02;
00205         m_aafMat[2][0] = 0.0; m_aafMat[2][1] = fM02; m_aafMat[2][2] = -fM01;
00206     }
00207     else
00208     {
00209         m_afDiag[1] = fM11;
00210         m_afDiag[2] = fM22;
00211         m_afSubd[0] = fM01;
00212         m_afSubd[1] = fM12;
00213         m_aafMat[0][0] = 1.0; m_aafMat[0][1] = 0.0; m_aafMat[0][2] = 0.0;
00214         m_aafMat[1][0] = 0.0; m_aafMat[1][1] = 1.0; m_aafMat[1][2] = 0.0;
00215         m_aafMat[2][0] = 0.0; m_aafMat[2][1] = 0.0; m_aafMat[2][2] = 1.0;
00216     }
00217 }

void gmtl::Eigen::Tridiagonal4 float **    aafMat,
float *    afDiag,
float *    afSubd
[static, protected]
 

Definition at line 219 of file Eigen.h.

References m_aafMat, m_afDiag, m_afSubd, and gmtl::Math::sqrt.

Referenced by DecrSortEigenStuff, DecrSortEigenStuff4, EigenStuff, EigenStuff4, IncrSortEigenStuff, and IncrSortEigenStuff4.

00221 {
00222     // save matrix M
00223     float fM00 = m_aafMat[0][0];
00224     float fM01 = m_aafMat[0][1];
00225     float fM02 = m_aafMat[0][2];
00226     float fM03 = m_aafMat[0][3];
00227     float fM11 = m_aafMat[1][1];
00228     float fM12 = m_aafMat[1][2];
00229     float fM13 = m_aafMat[1][3];
00230     float fM22 = m_aafMat[2][2];
00231     float fM23 = m_aafMat[2][3];
00232     float fM33 = m_aafMat[3][3];
00233 
00234     m_afDiag[0] = fM00;
00235     m_afSubd[3] = 0.0;
00236 
00237     m_aafMat[0][0] = 1.0;
00238     m_aafMat[0][1] = 0.0;
00239     m_aafMat[0][2] = 0.0;
00240     m_aafMat[0][3] = 0.0;
00241     m_aafMat[1][0] = 0.0;
00242     m_aafMat[2][0] = 0.0;
00243     m_aafMat[3][0] = 0.0;
00244 
00245     float fLength, fInvLength;
00246 
00247     if ( fM02 != 0.0 || fM03 != 0.0 )
00248     {
00249         float fQ11, fQ12, fQ13;
00250         float fQ21, fQ22, fQ23;
00251         float fQ31, fQ32, fQ33;
00252 
00253         // build column Q1
00254         fLength = Math::sqrt(fM01*fM01 + fM02*fM02 + fM03*fM03);
00255         fInvLength = 1.0/fLength;
00256         fQ11 = fM01*fInvLength;
00257         fQ21 = fM02*fInvLength;
00258         fQ31 = fM03*fInvLength;
00259 
00260         m_afSubd[0] = fLength;
00261 
00262         // compute S*Q1
00263         float fV0 = fM11*fQ11+fM12*fQ21+fM13*fQ31;
00264         float fV1 = fM12*fQ11+fM22*fQ21+fM23*fQ31;
00265         float fV2 = fM13*fQ11+fM23*fQ21+fM33*fQ31;
00266 
00267         m_afDiag[1] = fQ11*fV0+fQ21*fV1+fQ31*fV2;
00268 
00269         // build column Q3 = Q1x(S*Q1)
00270         fQ13 = fQ21*fV2-fQ31*fV1;
00271         fQ23 = fQ31*fV0-fQ11*fV2;
00272         fQ33 = fQ11*fV1-fQ21*fV0;
00273         fLength = Math::sqrt(fQ13*fQ13+fQ23*fQ23+fQ33*fQ33);
00274         if ( fLength > 0.0 )
00275         {
00276             fInvLength = 1.0/fLength;
00277             fQ13 *= fInvLength;
00278             fQ23 *= fInvLength;
00279             fQ33 *= fInvLength;
00280 
00281             // build column Q2 = Q3xQ1
00282             fQ12 = fQ23*fQ31-fQ33*fQ21;
00283             fQ22 = fQ33*fQ11-fQ13*fQ31;
00284             fQ32 = fQ13*fQ21-fQ23*fQ11;
00285 
00286             fV0 = fQ12*fM11+fQ22*fM12+fQ32*fM13;
00287             fV1 = fQ12*fM12+fQ22*fM22+fQ32*fM23;
00288             fV2 = fQ12*fM13+fQ22*fM23+fQ32*fM33;
00289             m_afSubd[1] = fQ11*fV0+fQ21*fV1+fQ31*fV2;
00290             m_afDiag[2] = fQ12*fV0+fQ22*fV1+fQ32*fV2;
00291             m_afSubd[2] = fQ13*fV0+fQ23*fV1+fQ33*fV2;
00292 
00293             fV0 = fQ13*fM11+fQ23*fM12+fQ33*fM13;
00294             fV1 = fQ13*fM12+fQ23*fM22+fQ33*fM23;
00295             fV2 = fQ13*fM13+fQ23*fM23+fQ33*fM33;
00296             m_afDiag[3] = fQ13*fV0+fQ23*fV1+fQ33*fV2;
00297         }
00298         else
00299         {
00300             // S*Q1 parallel to Q1, choose any valid Q2 and Q3
00301             m_afSubd[1] = 0;
00302 
00303             fLength = fQ21*fQ21+fQ31*fQ31;
00304             if ( fLength > 0.0 )
00305             {
00306                 fInvLength = 1.0/fLength;
00307                 float fTmp = fQ11-1.0;
00308                 fQ12 = -fQ21;
00309                 fQ22 = 1.0+fTmp*fQ21*fQ21*fInvLength;
00310                 fQ32 = fTmp*fQ21*fQ31*fInvLength;
00311 
00312                 fQ13 = -fQ31;
00313                 fQ23 = fQ32;
00314                 fQ33 = 1.0+fTmp*fQ31*fQ31*fInvLength;
00315 
00316                 fV0 = fQ12*fM11+fQ22*fM12+fQ32*fM13;
00317                 fV1 = fQ12*fM12+fQ22*fM22+fQ32*fM23;
00318                 fV2 = fQ12*fM13+fQ22*fM23+fQ32*fM33;
00319                 m_afDiag[2] = fQ12*fV0+fQ22*fV1+fQ32*fV2;
00320                 m_afSubd[2] = fQ13*fV0+fQ23*fV1+fQ33*fV2;
00321 
00322                 fV0 = fQ13*fM11+fQ23*fM12+fQ33*fM13;
00323                 fV1 = fQ13*fM12+fQ23*fM22+fQ33*fM23;
00324                 fV2 = fQ13*fM13+fQ23*fM23+fQ33*fM33;
00325                 m_afDiag[3] = fQ13*fV0+fQ23*fV1+fQ33*fV2;
00326             }
00327             else
00328             {
00329                 // Q1 = (+-1,0,0)
00330                 fQ12 = 0.0; fQ22 = 1.0; fQ32 = 0.0;
00331                 fQ13 = 0.0; fQ23 = 0.0; fQ33 = 1.0;
00332 
00333                 m_afDiag[2] = fM22;
00334                 m_afDiag[3] = fM33;
00335                 m_afSubd[2] = fM23;
00336             }
00337         }
00338 
00339         m_aafMat[1][1] = fQ11; m_aafMat[1][2] = fQ12; m_aafMat[1][3] = fQ13;
00340         m_aafMat[2][1] = fQ21; m_aafMat[2][2] = fQ22; m_aafMat[2][3] = fQ23;
00341         m_aafMat[3][1] = fQ31; m_aafMat[3][2] = fQ32; m_aafMat[3][3] = fQ33;
00342     }
00343     else
00344     {
00345         m_afDiag[1] = fM11;
00346         m_afSubd[0] = fM01;
00347         m_aafMat[1][1] = 1.0;
00348         m_aafMat[2][1] = 0.0;
00349         m_aafMat[3][1] = 0.0;
00350 
00351         if ( fM13 != 0.0 )
00352         {
00353             fLength = Math::sqrt(fM12*fM12+fM13*fM13);
00354             fInvLength = 1.0/fLength;
00355             fM12 *= fInvLength;
00356             fM13 *= fInvLength;
00357             float fQ = 2.0*fM12*fM23+fM13*(fM33-fM22);
00358 
00359             m_afDiag[2] = fM22+fM13*fQ;
00360             m_afDiag[3] = fM33-fM13*fQ;
00361             m_afSubd[1] = fLength;
00362             m_afSubd[2] = fM23-fM12*fQ;
00363             m_aafMat[1][2] = 0.0;
00364             m_aafMat[1][3] = 0.0;
00365             m_aafMat[2][2] = fM12;
00366             m_aafMat[2][3] = fM13;
00367             m_aafMat[3][2] = fM13;
00368             m_aafMat[3][3] = -fM12;
00369         }
00370         else
00371         {
00372             m_afDiag[2] = fM22;
00373             m_afDiag[3] = fM33;
00374             m_afSubd[1] = fM12;
00375             m_afSubd[2] = fM23;
00376             m_aafMat[1][2] = 0.0;
00377             m_aafMat[1][3] = 0.0;
00378             m_aafMat[2][2] = 1.0;
00379             m_aafMat[2][3] = 0.0;
00380             m_aafMat[3][2] = 0.0;
00381             m_aafMat[3][3] = 1.0;
00382         }
00383     }
00384 }

void gmtl::Eigen::TridiagonalN int    iSize,
float **    aafMat,
float *    afDiag,
float *    afSubd
[static, protected]
 

Definition at line 386 of file Eigen.h.

References gmtl::Math::abs, m_aafMat, m_afDiag, m_afSubd, and gmtl::Math::sqrt.

Referenced by DecrSortEigenStuff, DecrSortEigenStuffN, EigenStuff, EigenStuffN, IncrSortEigenStuff, and IncrSortEigenStuffN.

00388 {
00389     int i0, i1, i2, i3;
00390 
00391     for (i0 = iSize-1, i3 = iSize-2; i0 >= 1; i0--, i3--)
00392     {
00393         float fH = 0.0, fScale = 0.0;
00394 
00395         if ( i3 > 0 )
00396         {
00397             for (i2 = 0; i2 <= i3; i2++)
00398                 fScale += Math::abs(m_aafMat[i0][i2]);
00399             if ( fScale == 0 )
00400             {
00401                 m_afSubd[i0] = m_aafMat[i0][i3];
00402             }
00403             else
00404             {
00405                 float fInvScale = 1.0/fScale;
00406                 for (i2 = 0; i2 <= i3; i2++)
00407                 {
00408                     m_aafMat[i0][i2] *= fInvScale;
00409                     fH += m_aafMat[i0][i2]*m_aafMat[i0][i2];
00410                 }
00411                 float fF = m_aafMat[i0][i3];
00412                 float fG = Math::sqrt(fH);
00413                 if ( fF > 0.0 )
00414                     fG = -fG;
00415                 m_afSubd[i0] = fScale*fG;
00416                 fH -= fF*fG;
00417                 m_aafMat[i0][i3] = fF-fG;
00418                 fF = 0.0;
00419                 float fInvH = 1.0/fH;
00420                 for (i1 = 0; i1 <= i3; i1++)
00421                 {
00422                     m_aafMat[i1][i0] = m_aafMat[i0][i1]*fInvH;
00423                     fG = 0.0;
00424                     for (i2 = 0; i2 <= i1; i2++)
00425                         fG += m_aafMat[i1][i2]*m_aafMat[i0][i2];
00426                     for (i2 = i1+1; i2 <= i3; i2++)
00427                         fG += m_aafMat[i2][i1]*m_aafMat[i0][i2];
00428                     m_afSubd[i1] = fG*fInvH;
00429                     fF += m_afSubd[i1]*m_aafMat[i0][i1];
00430                 }
00431                 float fHalfFdivH = 0.5*fF*fInvH;
00432                 for (i1 = 0; i1 <= i3; i1++)
00433                 {
00434                     fF = m_aafMat[i0][i1];
00435                     fG = m_afSubd[i1] - fHalfFdivH*fF;
00436                     m_afSubd[i1] = fG;
00437                     for (i2 = 0; i2 <= i1; i2++)
00438                     {
00439                         m_aafMat[i1][i2] -= fF*m_afSubd[i2] +
00440                             fG*m_aafMat[i0][i2];
00441                     }
00442                 }
00443             }
00444         }
00445         else
00446         {
00447             m_afSubd[i0] = m_aafMat[i0][i3];
00448         }
00449 
00450         m_afDiag[i0] = fH;
00451     }
00452 
00453     m_afDiag[0] = m_afSubd[0] = 0;
00454     for (i0 = 0, i3 = -1; i0 <= iSize-1; i0++, i3++)
00455     {
00456         if ( m_afDiag[i0] )
00457         {
00458             for (i1 = 0; i1 <= i3; i1++)
00459             {
00460                 float fSum = 0;
00461                 for (i2 = 0; i2 <= i3; i2++)
00462                     fSum += m_aafMat[i0][i2]*m_aafMat[i2][i1];
00463                 for (i2 = 0; i2 <= i3; i2++)
00464                     m_aafMat[i2][i1] -= fSum*m_aafMat[i2][i0];
00465             }
00466         }
00467         m_afDiag[i0] = m_aafMat[i0][i0];
00468         m_aafMat[i0][i0] = 1;
00469         for (i1 = 0; i1 <= i3; i1++)
00470             m_aafMat[i1][i0] = m_aafMat[i0][i1] = 0;
00471     }
00472 
00473     // re-ordering if Eigen::QLAlgorithm is used subsequently
00474     for (i0 = 1, i3 = 0; i0 < iSize; i0++, i3++)
00475         m_afSubd[i3] = m_afSubd[i0];
00476     m_afSubd[iSize-1] = 0;
00477 }


Member Data Documentation

float** gmtl::Eigen::m_aafMat [protected]
 

Definition at line 85 of file Eigen.h.

Referenced by DecrSortEigenStuff, DecrSortEigenStuff2, DecrSortEigenStuff3, DecrSortEigenStuff4, DecrSortEigenStuffN, Eigen, EigenStuff, EigenStuff2, EigenStuff3, EigenStuff4, EigenStuffN, GetEigenvector, IncrSortEigenStuff, IncrSortEigenStuff2, IncrSortEigenStuff3, IncrSortEigenStuff4, IncrSortEigenStuffN, Matrix, QLAlgorithm, SetMatrix, Tridiagonal2, Tridiagonal3, Tridiagonal4, TridiagonalN, and ~Eigen.

float* gmtl::Eigen::m_afDiag [protected]
 

Definition at line 86 of file Eigen.h.

Referenced by DecrSortEigenStuff, DecrSortEigenStuff2, DecrSortEigenStuff3, DecrSortEigenStuff4, DecrSortEigenStuffN, Eigen, EigenStuff, EigenStuff2, EigenStuff3, EigenStuff4, EigenStuffN, GetEigenvalue, IncrSortEigenStuff, IncrSortEigenStuff2, IncrSortEigenStuff3, IncrSortEigenStuff4, IncrSortEigenStuffN, QLAlgorithm, Tridiagonal2, Tridiagonal3, Tridiagonal4, TridiagonalN, and ~Eigen.

float* gmtl::Eigen::m_afSubd [protected]
 

Definition at line 87 of file Eigen.h.

Referenced by DecrSortEigenStuff, DecrSortEigenStuff2, DecrSortEigenStuff3, DecrSortEigenStuff4, DecrSortEigenStuffN, Eigen, EigenStuff, EigenStuff2, EigenStuff3, EigenStuff4, EigenStuffN, IncrSortEigenStuff, IncrSortEigenStuff2, IncrSortEigenStuff3, IncrSortEigenStuff4, IncrSortEigenStuffN, QLAlgorithm, Tridiagonal2, Tridiagonal3, Tridiagonal4, TridiagonalN, and ~Eigen.

int gmtl::Eigen::m_iSize [protected]
 

Definition at line 84 of file Eigen.h.

Referenced by DecrSortEigenStuff, DecrSortEigenStuff2, DecrSortEigenStuff3, DecrSortEigenStuff4, DecrSortEigenStuffN, Eigen, EigenStuff, EigenStuff2, EigenStuff3, EigenStuff4, EigenStuffN, IncrSortEigenStuff, IncrSortEigenStuff2, IncrSortEigenStuff3, IncrSortEigenStuff4, IncrSortEigenStuffN, SetMatrix, and ~Eigen.


The documentation for this class was generated from the following file:
Generated on Mon Apr 7 15:29:27 2003 for GenericMathTemplateLibrary by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002