• Main Page
  • Related Pages
  • Classes
  • Files
  • File List
  • File Members

GeneralRealMatrix.hh

Go to the documentation of this file.
00001 #ifndef _GENERAL_REAL_MATRIX_H
00002 #define _GENERAL_REAL_MATRIX_H
00003 
00004 #ifndef _OCS_SYSTEM_HDRS_
00005 #define _OCS_SYSTEM_HDRS_
00006 
00007 #include <iostream.h>
00008 #include <string.h>
00009 #include <math.h> 
00010 
00011 #include <fstream.h>
00012 #include <complex.h>
00013 #include <stdlib.h>
00014 #include <stdio.h>
00015 #include <strstream>
00016 
00017 #include <string>
00018   using namespace std;
00019 
00020 
00021 #endif /* _OCS_SYSTEM_HDRS_ */
00022 
00023 #include "ocsConst.hh"
00024 
00025 // For most compliers Fortran77 subroutines like myfun are recognized
00026 // as myfun_ Therefore:
00027 
00028 #define F77NAME(x) x##_
00029 
00030 extern "C" void F77NAME(dgetrf) (int*, int*, double*,int*,int*,int*);
00031 
00032 extern "C" void F77NAME(dgetrs)(char*,int*,int*,double*,int*,int*,double*,
00033                                 int*,int*);
00034                 
00035 extern "C" void F77NAME(dsyev)(char*,char*,int*,double*,int*,double*,double*,
00036                                int*,int*);
00037 
00038 // The last argument is an int which is the length of the
00039 // character array name.
00040 
00041 extern "C" int F77NAME(ilaenv)(int*,char*,char*,int*,int*,int*,int*,int);
00042 
00043 class GeneralRealMatrix
00044 {
00045 
00046 public:
00047 
00048   GeneralRealMatrix(int NumRows2, int NumCol2);      
00049   GeneralRealMatrix(const GeneralRealMatrix & Copy);       
00050 
00051   ~GeneralRealMatrix(void);
00052 
00053   void WriteFileMatrix(string OutFileName);
00054 
00057 
00065   inline double Get(int i, int j) const
00066    {
00067      BoundsCheck(i,j);
00068      return Data[ (i-1) + (j-1) * NumRows ];
00069    };
00070 
00073 
00074   inline void Set(int i, int j, double Val)
00075    {
00076     BoundsCheck(i,j);
00077     Data[ (i-1) + (j-1) * NumRows ] = Val;
00078    };
00079 
00081 
00084   inline double & Element(int i, int j)
00085   {
00086     BoundsCheck(i,j);
00087     return Data[ (i-1) + (j-1) * NumRows ];
00088   }
00089 
00090 
00091   inline int GetNumRows(void) const { return NumRows; };
00092   inline int GetNumCols(void) const { return NumCols; };
00093 
00095 
00096   void SetAll(double Val);
00097 
00099 
00100   void Zero(void);
00101 
00103 
00104   void Multiply(const GeneralRealMatrix & A, const GeneralRealMatrix & B);
00105 
00107 
00108   void MultiplyTrans(const GeneralRealMatrix & A, const GeneralRealMatrix & B);
00109 
00111 
00112   void Image(const GeneralRealMatrix & X, GeneralRealMatrix & Y) const;
00113 
00115 
00116   void Symmetrize(void);
00117  
00119 
00120   void Transpose(GeneralRealMatrix & Atrans) const;
00121 
00124 
00125   int Solve( GeneralRealMatrix& X, const GeneralRealMatrix& B) const;
00126 
00129 
00130   void SymmetricEig(GeneralRealMatrix & EigValue,
00131                     GeneralRealMatrix & EigVector) const;
00132  
00133   double* Data;
00134 
00135 private:  
00136 
00137   inline void BoundsCheck(int i, int j) const
00138    {
00139      if( i > NumRows || i < 1)
00140        {  
00141          cerr << "GeneralRealMatrix::BoundsCheck: Row index out of bounds."
00142               << endl
00143               << "ABORT" << endl;
00144          exit(1);
00145        }
00146 
00147      if( j > NumCols || j < 1)
00148        {  
00149         cerr << "GeneralRealMatrix::BoundsCheck: Col index out of bounds."
00150               << endl
00151               << "ABORT" << endl;
00152          exit(1);
00153        }
00154    }
00155 
00156 
00157   int NumRows;
00158   int NumCols;
00159 
00160 };
00161 
00162 #endif // ## _GENERAL_REAL_MATRIX_H

Generated on Fri Jul 2 2010 12:57:46 for OCS by  doxygen 1.7.1