You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
2.7 KiB

  1. #ifndef STORM_SOLVER_LINEAREQUATIONSOLVER_H_
  2. #define STORM_SOLVER_LINEAREQUATIONSOLVER_H_
  3. #include <vector>
  4. #include "src/storage/SparseMatrix.h"
  5. namespace storm {
  6. namespace solver {
  7. /*!
  8. * An interface that represents an abstract linear equation solver. In addition to solving a system of linear
  9. * equations, the functionality to repeatedly multiply a matrix with a given vector is provided.
  10. */
  11. template<class Type>
  12. class LinearEquationSolver {
  13. public:
  14. virtual ~LinearEquationSolver() {
  15. // Intentionally left empty.
  16. }
  17. /*!
  18. * Solves the equation system A*x = b. The matrix A is required to be square and have a unique solution.
  19. * The solution of the set of linear equations will be written to the vector x. Note that the matrix A has
  20. * to be given upon construction time of the solver object.
  21. *
  22. * @param x The solution vector that has to be computed. Its length must be equal to the number of rows of A.
  23. * @param b The right-hand side of the equation system. Its length must be equal to the number of rows of A.
  24. * @param multiplyResult If non-null, this memory is used as a scratch memory. If given, the length of this
  25. * vector must be equal to the number of rows of A.
  26. */
  27. virtual void solveEquationSystem(std::vector<Type>& x, std::vector<Type> const& b, std::vector<Type>* multiplyResult = nullptr) const = 0;
  28. /*!
  29. * Performs repeated matrix-vector multiplication, using x[0] = x and x[i + 1] = A*x[i] + b. After
  30. * performing the necessary multiplications, the result is written to the input vector x. Note that the
  31. * matrix A has to be given upon construction time of the solver object.
  32. *
  33. * @param x The initial vector with which to perform matrix-vector multiplication. Its length must be equal
  34. * to the number of rows of A.
  35. * @param b If non-null, this vector is added after each multiplication. If given, its length must be equal
  36. * to the number of rows of A.
  37. * @param multiplyResult If non-null, this memory is used as a scratch memory. If given, the length of this
  38. * vector must be equal to the number of rows of A.
  39. */
  40. virtual void performMatrixVectorMultiplication(std::vector<Type>& x, std::vector<Type> const* b = nullptr, uint_fast64_t n = 1, std::vector<Type>* multiplyResult = nullptr) const = 0;
  41. };
  42. } // namespace solver
  43. } // namespace storm
  44. #endif /* STORM_SOLVER_LINEAREQUATIONSOLVER_H_ */