00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef MS_MATRIX_HPP
00011 #define MS_MATRIX_HPP
00012
00013
00014 #include <vector>
00015
00016 namespace matrix_science
00017 {
00023
00024
00035 class MS_MASCOTRESFILE_API ms_matrix
00036 {
00037 public:
00038
00039 typedef std::vector<double> column_vector_t;
00040 typedef std::vector<column_vector_t> matrix_t;
00041
00043 static ms_matrix diagonalMatrix(size_t s, double v);
00044
00046 static ms_matrix identityMatrix(size_t s);
00047
00049 static ms_matrix rowMatrix(const std::vector<double> & v);
00050
00052 static ms_matrix columnMatrix(const std::vector<double> & v);
00053
00055 ms_matrix();
00056
00058 ms_matrix(const matrix_t & m);
00059
00061 ms_matrix(size_t si, size_t sj, double v = 0.0);
00062
00064 size_t sizei() const;
00065
00067 size_t sizej() const;
00068
00069 #ifndef SWIG
00070
00071 column_vector_t & operator[](size_t i);
00072
00074 const column_vector_t & operator[](size_t i) const;
00075 #endif
00076
00077 double getCR(size_t i, size_t j) const;
00079 void setCR(size_t i, size_t j, double value);
00080
00082 double getRC(size_t i, size_t j) const { return getCR(j, i); }
00084 void setRC(size_t i, size_t j, double value) { setCR(j, i, value); }
00085
00087 const matrix_t & data() const;
00088 #ifndef SWIG
00089
00090 bool operator==(const ms_matrix & m) const;
00091
00093 bool operator!=(const ms_matrix & m) const;
00094
00096 ms_matrix operator*(const ms_matrix & m) const;
00097 #endif
00098
00099 bool isZero() const;
00100
00102 void resize(size_t si, size_t sj, double v = 0.0);
00103
00105 double multiplyByRow(const std::vector<double> & column, size_t row) const;
00106
00108 void setColumnDown(size_t row, size_t col, const std::vector<double> & vec);
00109
00111 void setColumnUp(size_t row, size_t col, const std::vector<double> & vec);
00112
00114 void transpose();
00115
00117 void logContents(ms_errs & errs, const char * description) const;
00118
00119 private:
00120 matrix_t matrix_;
00121 };
00122
00124 }
00125
00126 #endif // MS_MATRIX_HPP
00127
00128