00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GPPMATRIX_H
00021 #define GPPMATRIX_H
00022
00023
00024
00025
00026 #include <math.h>
00027
00028
00029
00030
00031
00032
00033 #include <gsl/gsl_matrix.h>
00034 #include <gsl/gsl_math.h>
00035 #include <gsl/gsl_blas.h>
00036 #include <gsl/gsl_eigen.h>
00037 #include <gsl/gsl_linalg.h>
00038
00039
00040
00041
00042
00043
00044 #include <SawObject.h>
00045
00046 class SawVector ;
00047 class SawVectorList ;
00048
00049
00050
00061 class SawMatrix : public SawObject
00062 {
00063 public:
00068 SawMatrix( uint rows , uint cols , double a = 0.0 );
00069 SawMatrix( double* array, uint rows, uint cols );
00070 SawMatrix( const SawMatrix& m );
00071 void operator = ( const SawMatrix& m );
00072 ~SawMatrix();
00074
00075 void swapRows( uint i, uint j ) ;
00076 void swapColumns( uint i, uint j ) ;
00077
00078 gsl_matrix* getGSLMatrix() const ;
00079 void setGSLMatrix( gsl_matrix* matrix ) ;
00080 uint getRows() const ;
00081 uint getColumns() const ;
00082 double get( uint i, uint j ) const;
00083 void set( uint i, uint j, double value );
00084
00085 void setIdentity() ;
00086 void setNull() ;
00087
00088 bool operator == ( SawMatrix m );
00089 bool operator != ( SawMatrix m );
00090
00091 double getMax( uint* i=NULL, uint *j=NULL ) const ;
00092 double getMin( uint* i=NULL, uint *j=NULL ) const ;
00093
00094 double getDeterminant() ;
00095 SawMatrix getInverse() ;
00096 SawVector getEigenValues( SawVectorList* eigenVectors = NULL ) ;
00097
00098 bool isNull() const ;
00099
00100 SawMatrix getTransPose() ;
00101
00106 friend SawMatrix operator + ( SawMatrix a, SawMatrix b ) ;
00107 friend SawMatrix operator - ( SawMatrix a, SawMatrix b ) ;
00108 friend SawMatrix operator * ( SawMatrix a, SawMatrix b ) ;
00109
00110 friend SawMatrix operator * ( SawMatrix m, double a ) ;
00111 friend SawMatrix operator * ( double a, SawMatrix m ) ;
00113
00118 friend ostream& operator << ( ostream& os, const SawMatrix& m ) ;
00119 friend istream& operator >> ( istream& is, const SawMatrix& m ) ;
00121
00126 static SawMatrix genericFunction( SawMatrix a, double(* func)(double) ) ;
00127 static SawMatrix genericFunction( SawMatrix a, double(* func)(double, double), double param = 0.0 ) ;
00128 static SawMatrix sin( SawMatrix a ) ;
00129 static SawMatrix cos( SawMatrix a ) ;
00130 static SawMatrix tan( SawMatrix a ) ;
00131 static SawMatrix asin( SawMatrix a ) ;
00132 static SawMatrix acos( SawMatrix a ) ;
00133 static SawMatrix atan( SawMatrix a ) ;
00134 static SawMatrix sinh( SawMatrix a ) ;
00135 static SawMatrix cosh( SawMatrix a ) ;
00136 static SawMatrix exp( SawMatrix a ) ;
00137 static SawMatrix ln( SawMatrix a ) ;
00138 static SawMatrix log( SawMatrix a ) ;
00139 static SawMatrix sqrt( SawMatrix a ) ;
00140 static SawMatrix pow( SawMatrix a, double e ) ;
00142
00143 private:
00144 static SawMatrix genericFunc( SawMatrix a, double(* func)(double) ) ;
00145
00146 private:
00147 gsl_matrix* matrix ;
00148 uint rows ;
00149 uint cols ;
00150 };
00151
00152 #endif