MTL4Solver.h 2.65 KB
 Naumann, Andreas committed May 15, 2011 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 ``````// ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // ============================================================================ // == == // == TU Dresden == // == == // == Institut für Wissenschaftliches Rechnen == // == Zellescher Weg 12-14 == // == 01069 Dresden == // == germany == // == == // ============================================================================ // == == // == https://gforge.zih.tu-dresden.de/projects/amdis/ == // == == // ============================================================================ #ifndef MTL4SOLVER_H #define MTL4SOLVER_H #include "OEMSolver.h" #include "MatrixStreams.h" #include namespace AMDiS { `````` Thomas Witkowski committed Jun 06, 2011 29 30 31 32 `````` template< typename MTLMatrix, typename MTLVector, typename Worker > class MTL4Solver : public OEMSolver { protected: Worker worker; `````` Naumann, Andreas committed May 15, 2011 33 `````` `````` Thomas Witkowski committed Jun 06, 2011 34 35 36 37 38 39 40 `````` template< typename Matrix, typename Vector, typename Mapper > int solve(const Matrix& A, Vector& x, Vector& b, Mapper& mapper) { MTLMatrix matrix(mapper.nRow(), mapper.nCol()); set_to_zero(matrix); MatMap< const Matrix, Mapper > matMap(A,mapper); matrix << matMap; `````` Naumann, Andreas committed May 15, 2011 41 `````` `````` Thomas Witkowski committed Jun 06, 2011 42 43 44 45 `````` MTLVector mtl_x(mapper.nRow()); set_to_zero(mtl_x); VecMap< Vector, Mapper > xVecMap(x, mapper); mtl_x << xVecMap; `````` Naumann, Andreas committed May 15, 2011 46 `````` `````` Thomas Witkowski committed Jun 06, 2011 47 48 49 50 `````` MTLVector mtl_b(mapper.nRow()); set_to_zero(mtl_b); VecMap< Vector, Mapper> bVecMap(b, mapper); mtl_b << bVecMap; `````` Naumann, Andreas committed May 15, 2011 51 `````` `````` Thomas Witkowski committed Jun 06, 2011 52 `````` error = worker.solve(matrix, mtl_x, mtl_b); `````` Naumann, Andreas committed May 15, 2011 53 `````` `````` Thomas Witkowski committed Jun 06, 2011 54 55 56 `````` mtl_x >> xVecMap; return error; } `````` Naumann, Andreas committed May 15, 2011 57 `````` `````` Thomas Witkowski committed Jun 06, 2011 58 59 60 61 62 `````` public: MTL4Solver(std::string n): OEMSolver(n), worker(this) {} `````` Naumann, Andreas committed May 15, 2011 63 `````` `````` Thomas Witkowski committed Jun 06, 2011 64 `````` virtual int solveSystem(const SolverMatrix >& A, `````` Naumann, Andreas committed May 15, 2011 65 66 67 `````` SystemVector& x, SystemVector& b, VectorialMapper& m) `````` Thomas Witkowski committed Jun 06, 2011 68 69 70 `````` { return solve(A,x,b,m); } `````` Naumann, Andreas committed May 15, 2011 71 72 73 74 75 `````` }; } #endif``````