00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef MGCEIGEN_H
00014 #define MGCEIGEN_H
00015
00016 #include "MgcMath.h"
00017
00018
00019 class MgcEigen
00020 {
00021 public:
00022 MgcEigen (int iSize);
00023 ~MgcEigen ();
00024
00025
00026 MgcReal& Matrix (int iRow, int iCol);
00027 void SetMatrix (MgcReal** aafMat);
00028
00029
00030 MgcReal GetEigenvalue (int i) const;
00031 MgcReal GetEigenvector (int iRow, int iCol) const;
00032 MgcReal* GetEigenvalue ();
00033 MgcReal** GetEigenvector ();
00034
00035
00036 void EigenStuff2 ();
00037 void EigenStuff3 ();
00038 void EigenStuff4 ();
00039 void EigenStuffN ();
00040 void EigenStuff ();
00041
00042
00043 void DecrSortEigenStuff2 ();
00044 void DecrSortEigenStuff3 ();
00045 void DecrSortEigenStuff4 ();
00046 void DecrSortEigenStuffN ();
00047 void DecrSortEigenStuff ();
00048
00049
00050 void IncrSortEigenStuff2 ();
00051 void IncrSortEigenStuff3 ();
00052 void IncrSortEigenStuff4 ();
00053 void IncrSortEigenStuffN ();
00054 void IncrSortEigenStuff ();
00055
00056 protected:
00057 int m_iSize;
00058 MgcReal** m_aafMat;
00059 MgcReal* m_afDiag;
00060 MgcReal* m_afSubd;
00061
00062
00063 static void Tridiagonal2 (MgcReal** aafMat, MgcReal* afDiag,
00064 MgcReal* afSubd);
00065 static void Tridiagonal3 (MgcReal** aafMat, MgcReal* afDiag,
00066 MgcReal* afSubd);
00067 static void Tridiagonal4 (MgcReal** aafMat, MgcReal* afDiag,
00068 MgcReal* afSubd);
00069 static void TridiagonalN (int iSize, MgcReal** aafMat, MgcReal* afDiag,
00070 MgcReal* afSubd);
00071
00072
00073 static bool QLAlgorithm (int iSize, MgcReal* afDiag, MgcReal* afSubd,
00074 MgcReal** aafMat);
00075
00076
00077 static void DecreasingSort (int iSize, MgcReal* afEigval,
00078 MgcReal** aafEigvec);
00079
00080
00081 static void IncreasingSort (int iSize, MgcReal* afEigval,
00082 MgcReal** aafEigvec);
00083 };
00084
00085
00086 inline MgcReal& MgcEigen::Matrix (int iRow, int iCol)
00087 {
00088 return m_aafMat[iRow][iCol];
00089 }
00090
00091 inline MgcReal MgcEigen::GetEigenvalue (int i) const
00092 {
00093 return m_afDiag[i];
00094 }
00095
00096 inline MgcReal MgcEigen::GetEigenvector (int iRow, int iCol) const
00097 {
00098 return m_aafMat[iRow][iCol];
00099 }
00100
00101 inline MgcReal* MgcEigen::GetEigenvalue ()
00102 {
00103 return m_afDiag;
00104 }
00105
00106 inline MgcReal** MgcEigen::GetEigenvector ()
00107 {
00108 return m_aafMat;
00109 }
00110
00111
00112 #endif