40 #ifndef __SIM_LINEAR_SOLVER_HH__
41 #define __SIM_LINEAR_SOLVER_HH__
62 assert(this->
eq.size() == rhs.
eq.size());
66 for (
unsigned i = 0;
i < res.eq.size();
i++)
67 res.
eq[
i] = this->eq[
i] + rhs.
eq[
i];
82 assert(unkw <
eq.size());
88 std::ostringstream oss;
89 for (
unsigned i = 0;
i <
eq.size();
i++) {
93 if (
i != eq.size() - 1)
101 unsigned cnt()
const {
return eq.size() - 1; }
112 for (
unsigned i = 0;
i < unknowns;
i++)
117 assert(eq <
matrix.size());
124 r +=
eq.toStr() +
"\n";
std::vector< double > solve() const
LinearSystem(unsigned unknowns)
LinearEquation & operator[](unsigned eq)
std::string toStr() const
LinearEquation(unsigned unknowns)
LinearEquation operator+(const LinearEquation &rhs)
std::vector< LinearEquation > matrix
double & operator[](unsigned unkw)
std::string toStr() const
This class describes a linear equation with constant coefficients.
std::vector< double > eq
Coefficients.
LinearEquation & operator*=(const double cnt)