| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/kernel/TeMatrix.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002 TerraLib - a library for developing GIS applications.
    00003 Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
    00004
    00005 This code is part of the TerraLib library.
    00006 This library is free software; you can redistribute it and/or
    00007 modify it under the terms of the GNU Lesser General Public
    00008 License as published by the Free Software Foundation; either
    00009 version 2.1 of the License, or (at your option) any later version.
    00010
    00011 You should have received a copy of the GNU Lesser General Public
    00012 License along with this library.
    00013
    00014 The authors reassure the license terms regarding the warranties.
    00015 They specifically disclaim any warranties, including, but not limited to,
    00016 the implied warranties of merchantability and fitness for a particular purpose.
    00017 The library provided hereunder is on an "as is" basis, and the authors have no
    00018 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00020 indirect, special, incidental, or consequential damages arising out of the use
    00021 of this library and its documentation.
    00022 *************************************************************************************/
    00026 #ifndef  __TERRALIB_INTERNAL_MATRIX_H
    00027 #define  __TERRALIB_INTERNAL_MATRIX_H
    00028
    00029 #include "TeDefines.h"
    00030 #include "TeAgnostic.h"
    00031
    00033 class TL_DLL TeMatrix
    00034 {
    00035 private:
    00036            int nrow;  // Number of rows
    00037            int ncol;  // Number of columns
    00038            double **mat;         // TeMatrix of double elements
    00039
    00041            short Alloc( int l, int c);
    00042
    00043 public:
    00045            TeMatrix();
    00046
    00048            TeMatrix(const TeMatrix& );
    00049
    00051            ~TeMatrix();
    00052
    00054            void Clear();
    00055
    00057            int Initialized(){ return ( nrow > 0 && ncol > 0 ) ? (true) : (false); }
    00058
    00060            int Init( int nrow = 1, int ncol = 1 , double* f=0);
    00061
    00063            int Init( int nrow , int ncol , double f  );
    00064
    00066            int Init(int k, double* f);
    00067
    00069            int Init(int k, double f);
    00070
    00072   inline const double& operator()( int lin, int col ) const {
    00073     TEAGN_DEBUG_CONDITION( ( ( lin >= 0 ) && ( lin < nrow ) &&
    00074       ( col >= 0 ) && ( col < ncol ) ),
    00075       "Trying to acces an invalid position" )
    00076
    00077     return mat[lin][col];
    00078   }
    00079
    00081            inline double& operator()( int lin, int col ){
    00082     TEAGN_DEBUG_CONDITION( ( ( lin >= 0 ) && ( lin < nrow ) &&
    00083       ( col >= 0 ) && ( col < ncol ) ),
    00084       "Trying to acces an invalid position" )
    00085
    00086     return mat[lin][col];
    00087            }
    00088
    00093   inline double const* const operator[]( int lin ) const
    00094   {
    00095     TEAGN_DEBUG_CONDITION( ( ( lin >= 0 ) && ( lin < nrow ) ),
    00096       "Trying to acces an invalid line" )
    00097
    00098     return mat[lin];
    00099   }
    00100
    00105   inline double* operator[]( int lin )
    00106   {
    00107     TEAGN_DEBUG_CONDITION( ( ( lin >= 0 ) && ( lin < nrow ) ),
    00108       "Trying to acces an invalid line" )
    00109
    00110     return mat[lin];
    00111   }
    00112
    00114            TeMatrix& operator=( const TeMatrix& m );
    00115
    00117            int        operator==(const TeMatrix& m) const;
    00118
    00120            void       operator*=(double);
    00121
    00123            TeMatrix   operator-();
    00124
    00126            int        Nrow() const { return nrow; }
    00127
    00129            int        Ncol()     const { return ncol; }
    00130
    00132            void Print() const;
    00133
    00135     void switchRows(int a ,int b);
    00136
    00138    void combineRows(int i,double b,int j);
    00139
    00141            int        Transpose( TeMatrix& mt ) const;
    00142
    00144            int        Inverse ( TeMatrix& mt ) const;
    00145
    00147            int        CholeskyInv (TeMatrix&           mt) const;
    00148
    00150            int MatTransf( TeMatrix& mt );
    00151
    00153            int isUpperTriangle() const;
    00154
    00156     int isLowerTriangle() const;
    00157
    00159            int        isSimetric()          const;
    00160
    00162            int        isPositiveDefinide() const;
    00163
    00165            int        CoFactor(int irow, int jcol, TeMatrix& m) const;
    00166
    00168            double     Determinant() const;
    00169
    00170 //         Extracts a triangle matrix from a simetric positive    definide one
    00171            int        CholeskyDecomp( TeMatrix& mt );
    00172
    00174            int        EigenVectors( TeMatrix& mt ) const;
    00175
    00177            int        EigenValues( TeMatrix& mt ) const;
    00178
    00180            int EigenVec( double e_vec[] );
    00181
    00186            double getTrace() const;
    00187
    00194   bool getPinv( TeMatrix& pinv ) const;
    00195
    00202   bool getSVD( TeMatrix& UMtx, TeMatrix& DMtx, TeMatrix& VMtx ) const;
    00203
    00205            friend TL_DLL TeMatrix operator+(const TeMatrix& m1,const TeMatrix& m2);
    00206
    00208            friend TL_DLL TeMatrix operator-(const TeMatrix&,const TeMatrix&);
    00209
    00211            friend TL_DLL TeMatrix operator*(const TeMatrix&,const TeMatrix&);
    00212
    00214            friend TL_DLL TeMatrix operator*(double c,const TeMatrix&);
    00215
    00222   static bool getIdentity( TeMatrix& identity, unsigned int width );
    00223
    00232   static bool getProduct( const TeMatrix& matrix1, const TeMatrix& matrix2,
    00233     TeMatrix& productMatrix );
    00234 };
    00235
    00236
    00237 #endif
    00238

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines