Implementation of Sparse Linear Solver. More...
#include <slufactor.h>
Public Types | |
Types | |
enum | UpdateType { ETA = 0 , FOREST_TOMLIN } |
Specifies how to perform change method. More... | |
using | Status = typename SLinSolver< R >::Status |
for convenience More... | |
Public Types inherited from SLinSolver< R > | |
enum | Status { OK = 0 , INSTABLE = 1 , SINGULAR = 2 , UNLOADED = 4 , ERROR = 8 } |
status flags of the SLinSolver class. More... | |
Public Member Functions | |
Update type | |
UpdateType | utype () const |
returns the current update type uptype. More... | |
void | setUtype (UpdateType tp) |
sets update type. More... | |
void | setMarkowitz (R m) |
sets minimum Markowitz threshold. More... | |
R | markowitz () |
returns Markowitz threshold. More... | |
Derived from SLinSolver | |
See documentation of SLinSolver for a documentation of these methods. | |
void | clear () |
int | dim () const |
int | memory () const |
const char * | getName () const |
Status | status () const |
R | stability () const |
R | matrixMetric (int type=0) const |
std::string | statistics () const |
Status | load (const SVectorBase< R > *vec[], int dim) |
Solve | |
void | solveRight (VectorBase< R > &x, const VectorBase< R > &b) |
Solves \(Ax=b\). More... | |
void | solveRight (SSVectorBase< R > &x, const SSVectorBase< R > &b) |
void | solveRight (SSVectorBase< R > &x, const SVectorBase< R > &b) |
Solves \(Ax=b\). More... | |
void | solveRight4update (SSVectorBase< R > &x, const SVectorBase< R > &b) |
Solves \(Ax=b\). More... | |
void | solve2right4update (SSVectorBase< R > &x, VectorBase< R > &y, const SVectorBase< R > &b, SSVectorBase< R > &d) |
Solves \(Ax=b\) and \(Ay=d\). More... | |
void | solve2right4update (SSVectorBase< R > &x, SSVectorBase< R > &y, const SVectorBase< R > &b, SSVectorBase< R > &d) |
Sparse version of solving two systems of equations. More... | |
void | solve3right4update (SSVectorBase< R > &x, VectorBase< R > &y, VectorBase< R > &z, const SVectorBase< R > &b, SSVectorBase< R > &d, SSVectorBase< R > &e) |
Solves \(Ax=b\), \(Ay=d\) and \(Az=e\). More... | |
void | solve3right4update (SSVectorBase< R > &x, SSVectorBase< R > &y, SSVectorBase< R > &z, const SVectorBase< R > &b, SSVectorBase< R > &d, SSVectorBase< R > &e) |
sparse version of solving three systems of equations More... | |
void | solveLeft (VectorBase< R > &x, const VectorBase< R > &b) |
sparse version of solving one system of equations with transposed basis matrix More... | |
void | solveLeft (SSVectorBase< R > &x, const SSVectorBase< R > &b) |
void | solveLeft (SSVectorBase< R > &x, const SVectorBase< R > &b) |
Solves \(Ax=b\). More... | |
void | solveLeft (SSVectorBase< R > &x, VectorBase< R > &y, const SVectorBase< R > &b, SSVectorBase< R > &d) |
Solves \(Ax=b\) and \(Ay=d\). More... | |
void | solveLeft (SSVectorBase< R > &x, SSVectorBase< R > &two, const SVectorBase< R > &b, SSVectorBase< R > &rhs2) |
sparse version of solving two systems of equations with transposed basis matrix More... | |
void | solveLeft (SSVectorBase< R > &x, VectorBase< R > &y, VectorBase< R > &z, const SVectorBase< R > &b, SSVectorBase< R > &d, SSVectorBase< R > &e) |
Solves \(Ax=b\), \(Ay=d\) and \(Az=e\). More... | |
void | solveLeft (SSVectorBase< R > &x, SSVectorBase< R > &y, SSVectorBase< R > &z, const SVectorBase< R > &b, SSVectorBase< R > &d, SSVectorBase< R > &e) |
sparse version of solving three systems of equations with transposed basis matrix More... | |
Status | change (int idx, const SVectorBase< R > &subst, const SSVectorBase< R > *eta=0) |
Miscellaneous | |
Real | getFactorTime () const |
time spent in factorizations More... | |
void | resetFactorTime () |
reset FactorTime More... | |
int | getFactorCount () const |
number of factorizations performed More... | |
Real | getSolveTime () const |
time spent in solves More... | |
void | resetSolveTime () |
reset SolveTime More... | |
int | getSolveCount () const |
number of solves performed More... | |
void | resetCounters () |
reset timers and counters More... | |
void | changeTimer (const Timer::TYPE ttype) |
void | dump () const |
prints the LU factorization to stdout. More... | |
bool | isConsistent () const |
consistency check. More... | |
virtual void | setTolerances (std::shared_ptr< Tolerances > tolerances) |
set tolerances More... | |
Constructors / Destructors | |
SLUFactor () | |
default constructor. More... | |
SLUFactor< R > & | operator= (const SLUFactor< R > &old) |
assignment operator. More... | |
SLUFactor (const SLUFactor< R > &old) | |
copy constructor. More... | |
virtual | ~SLUFactor () |
destructor. More... | |
virtual SLinSolver< R > * | clone () const |
clone function for polymorphism More... | |
Public Member Functions inherited from SLinSolver< R > | |
SLinSolver () | |
default constructor More... | |
virtual | ~SLinSolver () |
destructor More... | |
Protected Member Functions | |
Protected helpers | |
void | freeAll () |
void | changeEta (int idx, SSVectorBase< R > &eta) |
Protected Member Functions inherited from CLUFactor< R > | |
void | solveLright (R *vec) |
int | solveRight4update (R *vec, int *nonz, R eps, R *rhs, R *forest, int *forestNum, int *forestIdx) |
void | solveRight (R *vec, R *rhs) |
int | solveRight2update (R *vec1, R *vec2, R *rhs1, R *rhs2, int *nonz, R eps, R *forest, int *forestNum, int *forestIdx) |
void | solveRight2 (R *vec1, R *vec2, R *rhs1, R *rhs2) |
void | solveLeft (R *vec, R *rhs) |
int | solveLeftEps (R *vec, R *rhs, int *nonz, R eps) |
int | solveLeft2 (R *vec1, int *nonz, R *vec2, R eps, R *rhs1, R *rhs2) |
int | vSolveRight4update (R eps, R *vec, int *idx, R *rhs, int *ridx, int rn, R *forest, int *forestNum, int *forestIdx) |
int | vSolveRight4update2 (R eps, R *vec, int *idx, R *rhs, int *ridx, int rn, R *vec2, R eps2, R *rhs2, int *ridx2, int rn2, R *forest, int *forestNum, int *forestIdx) |
void | vSolveRight4update2sparse (R eps, R *vec, int *idx, R *rhs, int *ridx, int &rn, R eps2, R *vec2, int *idx2, R *rhs2, int *ridx2, int &rn2, R *forest, int *forestNum, int *forestIdx) |
sparse version of above method More... | |
int | vSolveRight4update3 (R eps, R *vec, int *idx, R *rhs, int *ridx, int rn, R *vec2, R eps2, R *rhs2, int *ridx2, int rn2, R *vec3, R eps3, R *rhs3, int *ridx3, int rn3, R *forest, int *forestNum, int *forestIdx) |
void | vSolveRight4update3sparse (R eps, R *vec, int *idx, R *rhs, int *ridx, int &rn, R eps2, R *vec2, int *idx2, R *rhs2, int *ridx2, int &rn2, R eps3, R *vec3, int *idx3, R *rhs3, int *ridx3, int &rn3, R *forest, int *forestNum, int *forestIdx) |
sparse version of above method More... | |
void | vSolveRightNoNZ (R *vec, R eps, R *rhs, int *ridx, int rn) |
int | vSolveLeft (R eps, R *vec, int *idx, R *rhs, int *ridx, int rn) |
void | vSolveLeftNoNZ (R eps, R *vec, R *rhs, int *ridx, int rn) |
int | vSolveLeft2 (R eps, R *vec, int *idx, R *rhs, int *ridx, int rn, R *vec2, R *rhs2, int *ridx2, int rn2) |
void | vSolveLeft2sparse (R eps, R *vec, int *idx, R *rhs, int *ridx, int &rn, R *vec2, int *idx2, R *rhs2, int *ridx2, int &rn2) |
sparse version of solving 2 systems of equations More... | |
int | vSolveLeft3 (R eps, R *vec, int *idx, R *rhs, int *ridx, int rn, R *vec2, R *rhs2, int *ridx2, int rn2, R *vec3, R *rhs3, int *ridx3, int rn3) |
void | vSolveLeft3sparse (R eps, R *vec, int *idx, R *rhs, int *ridx, int &rn, R *vec2, int *idx2, R *rhs2, int *ridx2, int &rn2, R *vec3, int *idx3, R *rhs3, int *ridx3, int &rn3) |
sparse version of solving 3 systems of equations More... | |
void | forestUpdate (int col, R *work, int num, int *nonz) |
void | update (int p_col, R *p_work, const int *p_idx, int num) |
void | updateNoClear (int p_col, const R *p_work, const int *p_idx, int num) |
void | factor (const SVectorBase< R > **vec, R threshold, R eps) |
void | dump () const |
bool | isConsistent () const |
void | setTolerances (std::shared_ptr< Tolerances > tolerances) |
set tolerances More... | |
const std::shared_ptr< Tolerances > | tolerances () const |
get tolerances More... | |
Protected Attributes | |
Protected data | |
bool | usetup |
TRUE iff update vector has been setup. More... | |
UpdateType | uptype |
the current UpdateType. More... | |
SSVectorBase< R > | eta |
SSVectorBase< R > | forest |
? Update VectorBase<R> set up by solveRight4update() and solve2right4update() More... | |
R | lastThreshold |
pivoting threshold of last factorization More... | |
Control Parameters | |
R | minThreshold |
minimum threshold to use. More... | |
R | minStability |
minimum stability to achieve by setting threshold. More... | |
Timer * | solveTime |
Time spent in solves. More... | |
Timer::TYPE | timerType |
int | solveCount |
Number of solves. More... | |
Protected Attributes inherited from CLUFactor< R > | |
SLinSolver< R >::Status | stat |
Status indicator. More... | |
int | thedim |
dimension of factorized matrix More... | |
int | nzCnt |
number of nonzeros in U More... | |
R | initMaxabs |
maximum abs number in initail Matrix More... | |
R | maxabs |
maximum abs number in L and U More... | |
R | rowMemMult |
factor of minimum Memory * number of nonzeros More... | |
R | colMemMult |
factor of minimum Memory * number of nonzeros More... | |
R | lMemMult |
factor of minimum Memory * number of nonzeros More... | |
Perm | row |
row permutation matrices More... | |
Perm | col |
column permutation matrices More... | |
L | l |
L matrix. More... | |
std::vector< R > | diag |
Array of pivot elements. More... | |
U | u |
U matrix. More... | |
R * | work |
Working array: must always be left as 0! More... | |
Timer * | factorTime |
Time spent in factorizations. More... | |
int | factorCount |
Number of factorizations. More... | |
int | hugeValues |
number of times huge values occurred during solve (only used in debug mode) More... | |
std::shared_ptr< Tolerances > | _tolerances |
Tolerances for the factorization. More... | |
Private Member Functions | |
Private helpers | |
void | assign (const SLUFactor< R > &old) |
used to implement the assignment operator More... | |
Private Attributes | |
Private data | |
VectorBase< R > | vec |
Temporary VectorBase<R> More... | |
SSVectorBase< R > | ssvec |
Temporary semi-sparse VectorBase<R> More... | |
Additional Inherited Members | |
Public Attributes inherited from SLinSolver< R > | |
SPxOut * | spxout |
message handler More... | |
Implementation of Sparse Linear Solver.
This class implements a SLinSolver interface by using the sparse LU factorization implemented in CLUFactor.
Definition at line 50 of file slufactor.h.
using Status = typename SLinSolver<R>::Status |
for convenience
Definition at line 64 of file slufactor.h.
enum UpdateType |
Specifies how to perform change method.
Enumerator | |
---|---|
ETA | |
FOREST_TOMLIN |
Definition at line 58 of file slufactor.h.
SLUFactor | ( | ) |
default constructor.
|
virtual |
destructor.
|
private |
used to implement the assignment operator
|
virtual |
Implements SLinSolver< R >.
|
protected |
void changeTimer | ( | const Timer::TYPE | ttype | ) |
Definition at line 293 of file slufactor.h.
References CLUFactor< R >::factorTime, SLUFactor< R >::solveTime, TimerFactory::switchTimer(), and SLUFactor< R >::timerType.
|
virtual |
Implements SLinSolver< R >.
|
virtual |
clone function for polymorphism
Implements SLinSolver< R >.
Definition at line 328 of file slufactor.h.
|
virtual |
Implements SLinSolver< R >.
Definition at line 164 of file slufactor.h.
References CLUFactor< R >::thedim.
void dump | ( | ) | const |
prints the LU factorization to stdout.
|
protected |
|
virtual |
number of factorizations performed
Implements SLinSolver< R >.
Definition at line 264 of file slufactor.h.
References CLUFactor< R >::factorCount.
Real getFactorTime | ( | ) | const |
time spent in factorizations
Definition at line 254 of file slufactor.h.
References CLUFactor< R >::factorTime, and Timer::time().
|
virtual |
Implements SLinSolver< R >.
Definition at line 174 of file slufactor.h.
int getSolveCount | ( | ) | const |
number of solves performed
Definition at line 280 of file slufactor.h.
References SLUFactor< R >::solveCount.
Real getSolveTime | ( | ) | const |
time spent in solves
Definition at line 270 of file slufactor.h.
References SLUFactor< R >::solveTime, and Timer::time().
|
virtual |
consistency check.
Implements SLinSolver< R >.
|
virtual |
Implements SLinSolver< R >.
R markowitz | ( | ) |
returns Markowitz threshold.
Definition at line 149 of file slufactor.h.
References SLUFactor< R >::lastThreshold.
|
virtual |
return one of several matrix metrics based on the diagonal of U 0: condition number estimate by ratio of min/max 1: trace (sum of diagonal elements) 2: determinant (product of diagonal elements)
Implements SLinSolver< R >.
|
virtual |
Implements SLinSolver< R >.
Definition at line 169 of file slufactor.h.
References CLUFactor< R >::L::firstUnused, CLUFactor< R >::l, CLUFactor< R >::nzCnt, and CLUFactor< R >::L::start.
void resetCounters | ( | ) |
reset timers and counters
Definition at line 285 of file slufactor.h.
References CLUFactor< R >::factorCount, CLUFactor< R >::factorTime, CLUFactor< R >::hugeValues, and Timer::reset().
void resetFactorTime | ( | ) |
reset FactorTime
Definition at line 259 of file slufactor.h.
References CLUFactor< R >::factorTime, and Timer::reset().
void resetSolveTime | ( | ) |
reset SolveTime
Definition at line 275 of file slufactor.h.
References Timer::reset(), and SLUFactor< R >::solveTime.
void setMarkowitz | ( | R | m | ) |
sets minimum Markowitz threshold.
Definition at line 136 of file slufactor.h.
References SLUFactor< R >::lastThreshold, and SLUFactor< R >::minThreshold.
|
virtual |
set tolerances
Definition at line 306 of file slufactor.h.
References CLUFactor< R >::_tolerances, SLUFactor< R >::forest, SSVectorBase< R >::setTolerances(), and CLUFactor< R >::tolerances().
void setUtype | ( | UpdateType | tp | ) |
sets update type.
The new UpdateType becomes valid only after the next call to method load().
Definition at line 130 of file slufactor.h.
References SLUFactor< R >::uptype.
|
virtual |
Sparse version of solving two systems of equations.
Implements SLinSolver< R >.
|
virtual |
Solves \(Ax=b\) and \(Ay=d\).
Implements SLinSolver< R >.
|
virtual |
sparse version of solving three systems of equations
Implements SLinSolver< R >.
|
virtual |
Solves \(Ax=b\), \(Ay=d\) and \(Az=e\).
Implements SLinSolver< R >.
|
virtual |
Implements SLinSolver< R >.
Definition at line 227 of file slufactor.h.
References SLUFactor< R >::solveLeft(), and SSVectorBase< R >::unSetup().
|
virtual |
Solves \(Ax=b\).
Implements SLinSolver< R >.
|
virtual |
sparse version of solving two systems of equations with transposed basis matrix
Implements SLinSolver< R >.
|
virtual |
sparse version of solving three systems of equations with transposed basis matrix
Implements SLinSolver< R >.
|
virtual |
Solves \(Ax=b\) and \(Ay=d\).
Implements SLinSolver< R >.
|
virtual |
Solves \(Ax=b\), \(Ay=d\) and \(Az=e\).
Implements SLinSolver< R >.
|
virtual |
sparse version of solving one system of equations with transposed basis matrix
Implements SLinSolver< R >.
Referenced by SLUFactor< R >::solveLeft().
|
virtual |
Implements SLinSolver< R >.
Definition at line 204 of file slufactor.h.
References SLUFactor< R >::solveRight(), and SSVectorBase< R >::unSetup().
|
virtual |
Solves \(Ax=b\).
Implements SLinSolver< R >.
|
virtual |
|
virtual |
Solves \(Ax=b\).
Implements SLinSolver< R >.
|
virtual |
Implements SLinSolver< R >.
|
virtual |
Implements SLinSolver< R >.
|
virtual |
Implements SLinSolver< R >.
Definition at line 179 of file slufactor.h.
References CLUFactor< R >::stat.
UpdateType utype | ( | ) | const |
returns the current update type uptype.
Definition at line 121 of file slufactor.h.
References SLUFactor< R >::uptype.
|
protected |
Definition at line 83 of file slufactor.h.
|
protected |
? Update VectorBase<R> set up by solveRight4update() and solve2right4update()
Definition at line 85 of file slufactor.h.
Referenced by SLUFactor< R >::setTolerances().
|
protected |
pivoting threshold of last factorization
Definition at line 86 of file slufactor.h.
Referenced by SLUFactor< R >::markowitz(), and SLUFactor< R >::setMarkowitz().
|
protected |
minimum stability to achieve by setting threshold.
Definition at line 95 of file slufactor.h.
|
protected |
minimum threshold to use.
Definition at line 93 of file slufactor.h.
Referenced by SLUFactor< R >::setMarkowitz().
|
protected |
Number of solves.
Definition at line 100 of file slufactor.h.
Referenced by SLUFactor< R >::getSolveCount().
|
protected |
Time spent in solves.
Definition at line 97 of file slufactor.h.
Referenced by SLUFactor< R >::changeTimer(), SLUFactor< R >::getSolveTime(), and SLUFactor< R >::resetSolveTime().
|
private |
Temporary semi-sparse VectorBase<R>
Definition at line 73 of file slufactor.h.
|
protected |
Definition at line 98 of file slufactor.h.
Referenced by SLUFactor< R >::changeTimer().
|
protected |
the current UpdateType.
Definition at line 82 of file slufactor.h.
Referenced by SLUFactor< R >::setUtype(), and SLUFactor< R >::utype().
|
protected |
TRUE iff update vector has been setup.
Definition at line 81 of file slufactor.h.
|
private |
Temporary VectorBase<R>
Definition at line 72 of file slufactor.h.