basic/geometry/geo_rangesensor/MgcEigen.h

Go to the documentation of this file.
00001 // Magic Software, Inc.
00002 // http://www.magic-software.com
00003 // Copyright (c) 2000, All Rights Reserved
00004 //
00005 // Source code from Magic Software is supplied under the terms of a license
00006 // agreement and may not be copied or disclosed except in accordance with the
00007 // terms of that agreement.  The various license agreements may be found at
00008 // the Magic Software web site.  This file is subject to the license
00009 //
00010 // FREE SOURCE CODE
00011 // http://www.magic-software.com/License.html/free.pdf
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     // set the matrix for eigensolving
00026     MgcReal& Matrix (int iRow, int iCol);
00027     void SetMatrix (MgcReal** aafMat);
00028 
00029     // get the results of eigensolving (eigenvectors are columns of matrix)
00030     MgcReal GetEigenvalue (int i) const;
00031     MgcReal GetEigenvector (int iRow, int iCol) const;
00032     MgcReal* GetEigenvalue ();
00033     MgcReal** GetEigenvector ();
00034 
00035     // solve eigensystem
00036     void EigenStuff2 ();
00037     void EigenStuff3 ();
00038     void EigenStuff4 ();
00039     void EigenStuffN ();
00040     void EigenStuff  ();
00041 
00042     // solve eigensystem, use decreasing sort on eigenvalues
00043     void DecrSortEigenStuff2 ();
00044     void DecrSortEigenStuff3 ();
00045     void DecrSortEigenStuff4 ();
00046     void DecrSortEigenStuffN ();
00047     void DecrSortEigenStuff  ();
00048 
00049     // solve eigensystem, use increasing sort on eigenvalues
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     // Householder reduction to tridiagonal form
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     // QL algorithm with implicit shifting, applies to tridiagonal matrices
00073     static bool QLAlgorithm (int iSize, MgcReal* afDiag, MgcReal* afSubd,
00074         MgcReal** aafMat);
00075 
00076     // sort eigenvalues from largest to smallest
00077     static void DecreasingSort (int iSize, MgcReal* afEigval,
00078         MgcReal** aafEigvec);
00079 
00080     // sort eigenvalues from smallest to largest
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

Generated on Sat Apr 1 21:30:31 2006 for Motion Planning Kernel by  doxygen 1.4.6-NO