gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
linearSystem.h
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #ifndef LINEAR_SYSTEM_H
7 #define LINEAR_SYSTEM_H
8 
9 #include <map>
10 #include <string>
11 
12 // A class that encapsulates a linear system solver interface :
13 // building a sparse matrix, solving a linear system
15 protected:
16  std::map<std::string, std::string> _parameters;
17 
18 public:
19  virtual ~linearSystemBase() {}
20  virtual bool isAllocated() const = 0;
21  virtual void allocate(int nbRows) = 0;
22  virtual void preAllocateEntries(){};
23  virtual void clear() = 0;
24  virtual void zeroMatrix() = 0;
25  virtual void zeroRightHandSide() = 0;
26  virtual void zeroSolution() = 0;
27  virtual int systemSolve() = 0;
28  // x = A*b
29  virtual int matMult() { return 0; }
30 
31  void setParameter(const std::string &key, std::string value);
32  std::string getParameter(const std::string &key) const;
33  virtual void insertInSparsityPattern(int _row, int _col){};
34  virtual double normInfRightHandSide() const = 0;
35  virtual double normInfSolution() const { return 0; };
36 };
37 
38 template <class scalar> class linearSystem : public linearSystemBase {
39 public:
41  virtual ~linearSystem() {}
42  virtual void addToMatrix(int _row, int _col, const scalar &val) = 0;
43  virtual void getFromMatrix(int _row, int _col, scalar &val) const = 0;
44  virtual void addToRightHandSide(int _row, const scalar &val, int ith = 0) = 0;
45  virtual void getFromRightHandSide(int _row, scalar &val) const = 0;
46  virtual void getFromSolution(int _row, scalar &val) const = 0;
47  virtual void addToSolution(int _row, const scalar &val) = 0;
48 };
49 
50 #endif
linearSystemBase::clear
virtual void clear()=0
linearSystemBase::systemSolve
virtual int systemSolve()=0
linearSystemBase::zeroRightHandSide
virtual void zeroRightHandSide()=0
linearSystemBase::_parameters
std::map< std::string, std::string > _parameters
Definition: linearSystem.h:16
linearSystemBase::zeroSolution
virtual void zeroSolution()=0
linearSystemBase::zeroMatrix
virtual void zeroMatrix()=0
linearSystem::linearSystem
linearSystem()
Definition: linearSystem.h:40
linearSystem::getFromRightHandSide
virtual void getFromRightHandSide(int _row, scalar &val) const =0
linearSystem::addToRightHandSide
virtual void addToRightHandSide(int _row, const scalar &val, int ith=0)=0
linearSystemBase::preAllocateEntries
virtual void preAllocateEntries()
Definition: linearSystem.h:22
linearSystem::addToSolution
virtual void addToSolution(int _row, const scalar &val)=0
linearSystemBase::isAllocated
virtual bool isAllocated() const =0
linearSystemBase::normInfRightHandSide
virtual double normInfRightHandSide() const =0
linearSystemBase::allocate
virtual void allocate(int nbRows)=0
linearSystemBase::setParameter
void setParameter(const std::string &key, std::string value)
Definition: linearSystem.cpp:10
linearSystemBase::~linearSystemBase
virtual ~linearSystemBase()
Definition: linearSystem.h:19
linearSystemBase::insertInSparsityPattern
virtual void insertInSparsityPattern(int _row, int _col)
Definition: linearSystem.h:33
linearSystemBase::matMult
virtual int matMult()
Definition: linearSystem.h:29
linearSystemBase
Definition: linearSystem.h:14
linearSystemBase::normInfSolution
virtual double normInfSolution() const
Definition: linearSystem.h:35
linearSystem::getFromMatrix
virtual void getFromMatrix(int _row, int _col, scalar &val) const =0
linearSystem::getFromSolution
virtual void getFromSolution(int _row, scalar &val) const =0
linearSystem::addToMatrix
virtual void addToMatrix(int _row, int _col, const scalar &val)=0
linearSystem::~linearSystem
virtual ~linearSystem()
Definition: linearSystem.h:41
linearSystemBase::getParameter
std::string getParameter(const std::string &key) const
Definition: linearSystem.cpp:17
linearSystem
Definition: linearSystem.h:38