LAMA
|
00001 00034 #ifndef LAMA_SIMPLESTORAGESTRATEGY_HPP_ 00035 #define LAMA_SIMPLESTORAGESTRATEGY_HPP_ 00036 00037 // for dll_import 00038 #include <lama/config.hpp> 00039 00040 // base classes 00041 #include <lama/matrix/Matrix.hpp> 00042 #include <lama/distribution/Distribution.hpp> 00043 #include <lama/Context.hpp> 00044 #include <lama/CommunicatorManager.hpp> 00045 00046 // spirit 00047 #include <boost/spirit/include/qi.hpp> 00048 00049 #include <string> 00050 #include <fstream> 00051 00052 namespace lama 00053 { 00054 00055 namespace phoenix = boost::phoenix; 00056 namespace qi = boost::spirit::qi; 00057 namespace ascii = boost::spirit::ascii; 00058 00059 template<typename ValueType> 00060 class LAMA_DLL_IMPORTEXPORT SimpleStorageStrategy : public SparseMatrix<ValueType> 00061 { 00062 public: 00063 typedef std::string::const_iterator StringIterator; 00064 00072 SimpleStorageStrategy( Matrix& other ); 00073 00077 virtual ~SimpleStorageStrategy(); 00078 00079 /* 00080 * @brief Decision method where the Strategies logic will be applied 00081 * In this method all current and relevant configurations are collected and used to create the 00082 * inner Matrix, which can be used as a usual SparseMatrix. 00083 * This method is called (usually internally) if a matrix data dependent is called from outside. 00084 */ 00085 void applyStrategy(); 00086 00090 virtual const char* getTypeName() const; 00091 00102 virtual void clear(); 00103 00113 virtual void allocate( const IndexType numRows, const IndexType numColumns ); 00114 00123 virtual void allocate( DistributionPtr rowDistribution, DistributionPtr colDistribution ); 00124 00135 virtual void setIdentity(); 00136 00143 virtual void assign( const Matrix& other ); 00144 00150 virtual void assign( const _MatrixStorage& other ); 00151 00154 virtual void assign( const _MatrixStorage& storage, DistributionPtr rowDist, DistributionPtr colDist ); 00155 00165 virtual void buildLocalStorage( _MatrixStorage& storage ) const; 00166 00173 virtual void redistribute( DistributionPtr rowDistribution , DistributionPtr colDistribution ); 00174 00184 virtual void getRow( Vector& row, const IndexType globalRowIndex ) const; 00185 00192 virtual void getDiagonal( Vector& diagonal ) const; 00193 00200 virtual void setDiagonal( const Vector& diagonal ); 00201 00208 virtual void setDiagonal( const Scalar scalar ); 00209 00216 virtual void scale( const Vector& scaling ); 00217 00222 virtual void scale( const Scalar scaling ); 00223 00233 virtual Scalar getValue( IndexType i, IndexType j ) const; 00234 00246 virtual IndexType getNumValues() const; 00247 00260 virtual void matrixTimesVector( 00261 Vector& result, const Scalar alpha, const Vector& x, 00262 const Scalar beta, const Vector& y ) const; 00263 00272 virtual void matrixTimesScalar( 00273 const Matrix& other, const Scalar alpha ); 00274 00286 virtual void matrixTimesMatrix( 00287 Matrix& result, const Scalar alpha, const Matrix& B, 00288 const Scalar beta, const Matrix& C ) const; 00289 00292 virtual IndexType getLocalNumValues() const; 00293 00296 virtual IndexType getLocalNumRows() const; 00297 00300 virtual IndexType getLocalNumColumns() const; 00301 00310 virtual void setContext( const ContextPtr context ); 00311 00317 virtual ContextPtr getContextPtr() const; 00318 00321 virtual MatrixKind getMatrixKind() const; 00322 00326 virtual void prefetch() const; 00327 00331 virtual void wait() const; 00332 00335 virtual void invert( const Matrix& other ); 00336 00346 virtual Scalar maxDiffNorm( const Matrix& other ) const; 00347 00372 virtual std::auto_ptr<Matrix> create() const; 00373 00386 virtual std::auto_ptr<Matrix> copy() const; 00387 00391 virtual Scalar::ScalarType getValueType() const; 00392 00397 virtual bool hasDiagonalProperty() const; 00398 00403 virtual void resetDiagonalProperty(); 00404 00413 virtual size_t getMemoryUsage() const; 00414 00415 private: 00416 /* 00417 * @brief Lazy generated Matrix 00418 * This matrix will be generated by a assign( Matrix& other ) call. 00419 */ 00420 MatrixPtr mInnerMatrix; 00421 00422 LAMA_LOG_DECL_STATIC_LOGGER(logger); 00423 00424 }; 00425 00426 } //namespace lama 00427 00428 #endif /* LAMA_SIMPLESTORAGESTRATEGY_HPP_ */