/* Copyright (C) 2006-2011 Evgenii Rudnyi, http://Evgenii.Rudnyi.Ru/ This software is a copyrighted work licensed under the terms, described in the file "FREE_LICENSE". */ #ifndef SOLVERS #define SOLVERS #include "matrices.h" namespace SolverError { struct SolverError : public BaseError { SolverError(const string &str1, const string &str2) : BaseError(string("SolverError::") + str1, str2) {} }; struct General : public SolverError { General(const string &str) : SolverError("General", str) {} }; struct TAUCS : public SolverError { TAUCS(const string &str) : SolverError("TAUCS", str) {} }; struct UMFPACK : public SolverError { UMFPACK(const string &str) : SolverError("UMFPACK", str) {} }; } //end namespace SolverError class LinearSolver { public: // memory management for matrices and factors is outside // to clear memory SetMatrix requires ClearMatrix // and factroring requires ClearFactor // clears matrix mat virtual void* setMatrix(SparseMatrix &mat) = 0; virtual void setVerbose() = 0; virtual void mulMatrixByVec(void *mat, double *in, double *out) = 0; virtual void* factor(void *mat, bool ClearMatrix, const string ¶m) = 0; virtual void mulInverseByVec(void *L, double *in, double *out) = 0; virtual void* copyMatrix(void *mat1) = 0; // mat1 = mat1 + alpha * mat2 // can we assume that nnz in mat2 is subset in mat1? Let us try it. virtual void sumMatrices(void *mat1, void* mat2, const double &alpha) = 0; virtual bool isSymmetric(void *mat) = 0; virtual bool supportSymmetric() = 0; virtual void clearMatrix(void *mat) = 0; virtual void clearFactor(void *L) = 0; virtual void clear() {} virtual ~LinearSolver() {clear();} //do not forget to delete it static LinearSolver* create(const string &str); }; #endif