| [a9b86d] | 1 | /* | 
|---|
|  | 2 | * MatrixContainer.hpp | 
|---|
|  | 3 | * | 
|---|
|  | 4 | *  Created on: Sep 15, 2011 | 
|---|
|  | 5 | *      Author: heber | 
|---|
|  | 6 | */ | 
|---|
|  | 7 |  | 
|---|
|  | 8 | #ifndef MATRIXCONTAINER_HPP_ | 
|---|
|  | 9 | #define MATRIXCONTAINER_HPP_ | 
|---|
|  | 10 |  | 
|---|
|  | 11 | // include config.h | 
|---|
|  | 12 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 13 | #include <config.h> | 
|---|
|  | 14 | #endif | 
|---|
|  | 15 |  | 
|---|
| [9758f7] | 16 | #include <vector> | 
|---|
| [a9b86d] | 17 |  | 
|---|
| [184d89] | 18 | #include "boost/serialization/serialization.hpp" | 
|---|
|  | 19 | #include <boost/serialization/split_member.hpp> | 
|---|
| [942906] | 20 | #include "boost/serialization/vector.hpp" | 
|---|
|  | 21 |  | 
|---|
| [a9b86d] | 22 | /** Contains a sequence of matrices parsed from file. | 
|---|
|  | 23 | * | 
|---|
|  | 24 | */ | 
|---|
|  | 25 | class MatrixContainer { | 
|---|
|  | 26 | public: | 
|---|
| [9758f7] | 27 | typedef std::vector<std::vector<double> > MatrixArray; | 
|---|
|  | 28 | typedef std::vector<MatrixArray> ArrayOfMatrices; | 
|---|
|  | 29 | typedef std::vector<std::string> StringVector; | 
|---|
|  | 30 | typedef std::vector<int> IntVector; | 
|---|
|  | 31 | typedef std::vector<IntVector> VectorOfIntVectors; | 
|---|
|  | 32 |  | 
|---|
|  | 33 | ArrayOfMatrices Matrix; | 
|---|
|  | 34 | VectorOfIntVectors Indices; | 
|---|
|  | 35 | StringVector Header; | 
|---|
| [a9b86d] | 36 | int MatrixCounter; | 
|---|
| [9758f7] | 37 | IntVector RowCounter; | 
|---|
|  | 38 | IntVector ColumnCounter; | 
|---|
| [a9b86d] | 39 |  | 
|---|
|  | 40 | MatrixContainer(); | 
|---|
|  | 41 | virtual ~MatrixContainer(); | 
|---|
|  | 42 |  | 
|---|
|  | 43 | bool InitialiseIndices(class MatrixContainer *Matrix = NULL); | 
|---|
| [9758f7] | 44 | bool ParseMatrix(std::istream &input, int skiplines, int skipcolumns, size_t MatrixNr); | 
|---|
| [a2d653] | 45 | bool AddMatrix(const std::string &header, const MatrixArray &matrix, size_t MatrixNr); | 
|---|
| [9758f7] | 46 | virtual bool ParseFragmentMatrix(const std::string name, const std::string prefix, std::string suffix, int skiplines, int skipcolumns); | 
|---|
|  | 47 | bool AllocateMatrix(StringVector GivenHeader, int MCounter, IntVector RCounter, IntVector CCounter); | 
|---|
| [a9b86d] | 48 | bool ResetMatrix(); | 
|---|
|  | 49 | double FindMinValue(); | 
|---|
|  | 50 | double FindMaxValue(); | 
|---|
|  | 51 | bool SetLastMatrix(double value, int skipcolumns); | 
|---|
| [9758f7] | 52 | bool SetLastMatrix(const MatrixArray &values, int skipcolumns); | 
|---|
| [a9b86d] | 53 | //bool ParseIndices(); | 
|---|
|  | 54 | //bool SumSubValues(); | 
|---|
|  | 55 | bool SumSubManyBodyTerms(class MatrixContainer &Matrix, class KeySetsContainer &KeySets, int Order); | 
|---|
| [9758f7] | 56 | bool WriteTotalFragments(const std::string name, const std::string prefix); | 
|---|
|  | 57 | bool WriteLastMatrix(const std::string name, const std::string prefix, const std::string suffix); | 
|---|
| [1b145f] | 58 |  | 
|---|
|  | 59 | bool operator==(const MatrixContainer &other) const; | 
|---|
|  | 60 |  | 
|---|
|  | 61 | bool operator!=(const MatrixContainer &other) const { | 
|---|
|  | 62 | return !(*this == other); | 
|---|
|  | 63 | } | 
|---|
| [942906] | 64 |  | 
|---|
|  | 65 | private: | 
|---|
|  | 66 | friend class boost::serialization::access; | 
|---|
|  | 67 | // serialization | 
|---|
| [184d89] | 68 | template <typename Archive> | 
|---|
|  | 69 | void load(Archive& ar, const unsigned int version) | 
|---|
| [942906] | 70 | { | 
|---|
| [184d89] | 71 | // default cstor resizes these three to 1, serialization will add more | 
|---|
|  | 72 | // members instead of starting new | 
|---|
|  | 73 | Header.clear(); | 
|---|
|  | 74 | RowCounter.clear(); | 
|---|
|  | 75 | ColumnCounter.clear(); | 
|---|
| [942906] | 76 | ar & Matrix; | 
|---|
|  | 77 | ar & Indices; | 
|---|
|  | 78 | ar & Header; | 
|---|
|  | 79 | ar & MatrixCounter; | 
|---|
|  | 80 | ar & RowCounter; | 
|---|
|  | 81 | ar & ColumnCounter; | 
|---|
|  | 82 | } | 
|---|
| [184d89] | 83 | template <typename Archive> | 
|---|
|  | 84 | void save(Archive& ar, const unsigned int version) const | 
|---|
|  | 85 | { | 
|---|
|  | 86 | ar & Matrix; | 
|---|
|  | 87 | ar & Indices; | 
|---|
|  | 88 | ar & Header; | 
|---|
|  | 89 | ar & MatrixCounter; | 
|---|
|  | 90 | ar & RowCounter; | 
|---|
|  | 91 | ar & ColumnCounter; | 
|---|
|  | 92 | } | 
|---|
|  | 93 |  | 
|---|
|  | 94 | BOOST_SERIALIZATION_SPLIT_MEMBER() | 
|---|
| [a9b86d] | 95 | }; | 
|---|
|  | 96 |  | 
|---|
|  | 97 | std::ostream & operator << (std::ostream &ost, const MatrixContainer &m); | 
|---|
|  | 98 |  | 
|---|
|  | 99 | #endif /* MATRIXCONTAINER_HPP_ */ | 
|---|