Implementation of Sparse Linear Solver.This class implements a SLinSolver interface by using the sparse LU factorization implemented in CLUFactor. 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... | |
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) |
| epsilon for zero detection More... | |
| void | dump () const |
| bool | isConsistent () const |
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... | |
| R | epsilon |
| |x| < epsililon is considered to be 0. 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... | |
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 41 of file slufactor.h.
| using Status = typename SLinSolver<R>::Status |
for convenience
Definition at line 55 of file slufactor.h.
| enum UpdateType |
Specifies how to perform change method.
| Enumerator | |
|---|---|
| ETA | |
| FOREST_TOMLIN | |
Definition at line 49 of file slufactor.h.
| SLUFactor | ( | ) |
default constructor.
|
virtual |
destructor.
|
private |
used to implement the assignment operator
Referenced by SLUFactor< R >::clone().
|
virtual |
Implements SLinSolver< R >.
Referenced by SLUFactor< R >::solveLeft().
|
protected |
| void changeTimer | ( | const Timer::TYPE | ttype | ) |
Definition at line 286 of file slufactor.h.
References SLUFactor< R >::dump(), CLUFactor< R >::factorTime, SLUFactor< R >::isConsistent(), SLUFactor< R >::operator=(), and TimerFactory::switchTimer().
|
virtual |
Implements SLinSolver< R >.
Referenced by SLUFactor< R >::markowitz().
|
virtual |
clone function for polymorphism
Implements SLinSolver< R >.
Definition at line 311 of file slufactor.h.
References SLUFactor< R >::assign().
|
virtual |
Implements SLinSolver< R >.
Definition at line 157 of file slufactor.h.
References CLUFactor< R >::thedim.
Referenced by SLUFactor< R >::status().
| void dump | ( | ) | const |
prints the LU factorization to stdout.
Referenced by SLUFactor< R >::changeTimer().
|
protected |
|
virtual |
number of factorizations performed
Implements SLinSolver< R >.
Definition at line 257 of file slufactor.h.
References CLUFactor< R >::factorCount.
| Real getFactorTime | ( | ) | const |
time spent in factorizations
Definition at line 247 of file slufactor.h.
References CLUFactor< R >::factorTime, and Timer::time().
|
virtual |
Implements SLinSolver< R >.
Definition at line 167 of file slufactor.h.
| int getSolveCount | ( | ) | const |
number of solves performed
Definition at line 273 of file slufactor.h.
References SLUFactor< R >::solveCount.
| Real getSolveTime | ( | ) | const |
|
virtual |
|
virtual |
Implements SLinSolver< R >.
Referenced by SLUFactor< R >::status().
| R markowitz | ( | ) |
returns Markowitz threshold.
Definition at line 142 of file slufactor.h.
References SLUFactor< R >::clear(), and 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 >.
Referenced by SLUFactor< R >::status().
|
virtual |
Implements SLinSolver< R >.
Definition at line 162 of file slufactor.h.
References CLUFactor< R >::L::firstUnused, CLUFactor< R >::l, CLUFactor< R >::nzCnt, and CLUFactor< R >::L::start.
assignment operator.
Referenced by SLUFactor< R >::changeTimer().
| void resetCounters | ( | ) |
reset timers and counters
Definition at line 278 of file slufactor.h.
References CLUFactor< R >::factorCount, CLUFactor< R >::factorTime, CLUFactor< R >::hugeValues, and Timer::reset().
| void resetFactorTime | ( | ) |
reset FactorTime
Definition at line 252 of file slufactor.h.
References CLUFactor< R >::factorTime, and Timer::reset().
| void resetSolveTime | ( | ) |
| void setMarkowitz | ( | R | m | ) |
sets minimum Markowitz threshold.
Definition at line 129 of file slufactor.h.
| void setUtype | ( | UpdateType | tp | ) |
sets update type.
The new UpdateType becomes valid only after the next call to method load().
Definition at line 123 of file slufactor.h.
|
virtual |
Solves \(Ax=b\) and \(Ay=d\).
Implements SLinSolver< R >.
Referenced by SLUFactor< R >::solveRight().
|
virtual |
Sparse version of solving two systems of equations.
Implements SLinSolver< R >.
|
virtual |
Solves \(Ax=b\), \(Ay=d\) and \(Az=e\).
Implements SLinSolver< R >.
Referenced by SLUFactor< R >::solveRight().
|
virtual |
sparse version of solving three systems of equations
Implements SLinSolver< R >.
|
virtual |
sparse version of solving one system of equations with transposed basis matrix
Implements SLinSolver< R >.
Referenced by SLUFactor< R >::solveLeft(), and SLUFactor< R >::solveRight().
|
virtual |
Implements SLinSolver< R >.
Definition at line 220 of file slufactor.h.
References SLUFactor< R >::change(), SLUFactor< R >::solveLeft(), and SSVectorBase< R >::unSetup().
|
virtual |
Solves \(Ax=b\).
Implements SLinSolver< R >.
|
virtual |
Solves \(Ax=b\) and \(Ay=d\).
Implements SLinSolver< R >.
|
virtual |
sparse version of solving two systems of equations with transposed basis matrix
Implements SLinSolver< R >.
|
virtual |
Solves \(Ax=b\), \(Ay=d\) and \(Az=e\).
Implements SLinSolver< R >.
|
virtual |
sparse version of solving three systems of equations with transposed basis matrix
Implements SLinSolver< R >.
|
virtual |
Solves \(Ax=b\).
Implements SLinSolver< R >.
Referenced by SLUFactor< R >::solveRight(), and SLUFactor< R >::status().
|
virtual |
Implements SLinSolver< R >.
Definition at line 197 of file slufactor.h.
References SLUFactor< R >::solve2right4update(), SLUFactor< R >::solve3right4update(), SLUFactor< R >::solveLeft(), SLUFactor< R >::solveRight(), SLUFactor< R >::solveRight4update(), and SSVectorBase< R >::unSetup().
|
virtual |
Solves \(Ax=b\).
Implements SLinSolver< R >.
|
virtual |
|
virtual |
Implements SLinSolver< R >.
Referenced by SLUFactor< R >::status().
|
virtual |
Implements SLinSolver< R >.
Referenced by SLUFactor< R >::status().
|
virtual |
Implements SLinSolver< R >.
Definition at line 172 of file slufactor.h.
References SLUFactor< R >::dim(), SLUFactor< R >::load(), SLUFactor< R >::matrixMetric(), SLUFactor< R >::solveRight(), SLUFactor< R >::stability(), CLUFactor< R >::stat, and SLUFactor< R >::statistics().
| UpdateType utype | ( | ) | const |
returns the current update type uptype.
Definition at line 114 of file slufactor.h.
References SLUFactor< R >::uptype.
|
protected |
|x| < epsililon is considered to be 0.
Definition at line 88 of file slufactor.h.
|
protected |
Definition at line 74 of file slufactor.h.
|
protected |
? Update VectorBase<R> set up by solveRight4update() and solve2right4update()
Definition at line 76 of file slufactor.h.
|
protected |
pivoting threshold of last factorization
Definition at line 77 of file slufactor.h.
Referenced by SLUFactor< R >::markowitz().
|
protected |
minimum stability to achieve by setting threshold.
Definition at line 86 of file slufactor.h.
|
protected |
minimum threshold to use.
Definition at line 84 of file slufactor.h.
|
protected |
Number of solves.
Definition at line 93 of file slufactor.h.
Referenced by SLUFactor< R >::getSolveCount().
|
protected |
Time spent in solves.
Definition at line 90 of file slufactor.h.
|
private |
Temporary semi-sparse VectorBase<R>
Definition at line 64 of file slufactor.h.
|
protected |
Definition at line 91 of file slufactor.h.
|
protected |
the current UpdateType.
Definition at line 73 of file slufactor.h.
Referenced by SLUFactor< R >::utype().
|
protected |
TRUE iff update vector has been setup.
Definition at line 72 of file slufactor.h.
|
private |
Temporary VectorBase<R>
Definition at line 63 of file slufactor.h.