OBOE 0.1
|
00001 // Copyright (c) 2004-2007 University of Geneva, HEC, Logilab 00002 // 00003 // OBOE is published under the Common Public License. 00004 // 00005 // Authors : 00006 // Nidhi Sawhney <nsawhney@yahoo.com> 00007 // The OBOE team 00008 // 00009 00010 #ifndef ACCPM_GENMATRIX_H 00011 #define ACCPM_GENMATRIX_H 00012 00013 #include "gmd.h" 00014 #include "symd.h" 00015 00016 #include "AccpmVector.h" 00017 #include "config.h" 00018 #ifdef SERIALIZATION 00019 #include <boost/archive/text_iarchive.hpp> 00020 #include <boost/archive/text_oarchive.hpp> 00021 #include <boost/serialization/base_object.hpp> 00022 #include <boost/serialization/split_member.hpp> 00023 #endif 00024 00030 //typedef LaSymmMatDouble SymmetricMatrix; 00031 00032 namespace Accpm 00033 { 00034 typedef LaGenMatDouble RealMatrix; 00035 typedef LaSymmMatDouble SymmetricMatrix; 00040 class AccpmGenMatrix : public RealMatrix { 00041 00042 #ifdef SERIALIZATION 00043 friend class boost::serialization::access; 00044 template<class Archive> 00045 void save(Archive &ar, const unsigned int file_version) const 00046 { 00047 int m = size(0); 00048 int n = size(1); 00049 ar & m & n; 00050 for (int i = 0; i < size(0) * size(1); ++i) { 00051 ar & *(addr() + i); 00052 } 00053 } 00054 00055 template<class Archive> 00056 void load(Archive &ar, const unsigned int file_version) 00057 { 00058 int m, n; 00059 ar & m & n; 00060 resize(m, n); 00061 for (int i = 0; i < m * n; ++i) { 00062 ar & *(addr() + i); 00063 } 00064 } 00065 BOOST_SERIALIZATION_SPLIT_MEMBER() 00066 #endif 00067 00068 public: 00069 // Operations of RealMatrix 00070 AccpmGenMatrix(); 00071 AccpmGenMatrix(int m, int n); 00072 AccpmGenMatrix(double *v, int m, int n, 00073 bool row_ordering); 00074 AccpmGenMatrix(const AccpmGenMatrix &); 00075 AccpmGenMatrix(const RealMatrix &); 00076 AccpmGenMatrix(const AccpmVector &); 00077 00078 virtual ~AccpmGenMatrix() {}; 00079 00080 #if (defined(LINUX)) // The following do not work correctly on Windows .NET 2003 00081 inline AccpmGenMatrix operator()(const LaIndex& I, const LaIndex& J) const 00082 { return RealMatrix::operator()(I,J); } 00083 inline AccpmGenMatrix operator()(const LaIndex& I, const LaIndex& J) 00084 { return RealMatrix::operator()(I,J); } 00085 inline double& operator()(int i, int j) { return RealMatrix::operator()(i,j); } 00086 #endif 00087 00088 //New AccpmGenMatrix operations 00089 AccpmGenMatrix* transpose() const; 00090 00091 AccpmGenMatrix& operator=(double s); 00092 AccpmGenMatrix& operator=(const AccpmGenMatrix &s); 00093 RealVector getColumn(int i) const; 00094 RealVector getRow(int i) const; 00095 00096 void scaleColumn(int i, double d); 00101 void scaleColumn(int i, const AccpmVector &d); 00102 void assignColumn(int colId, const AccpmVector &v); 00103 void assignRow(int rowId, const AccpmVector &v); 00107 void addMult(double scale, const AccpmGenMatrix &b); 00111 void scale(double scale); 00112 }; 00113 } 00114 00115 #endif