latest version v1.9 - last update 10 Apr 2010 |
Forward substitution. More...
#include <ltiForwardSubstitution.h>
Classes | |
class | parameters |
the parameters for the class forwardSubstitution More... | |
Public Member Functions | |
forwardSubstitution () | |
forwardSubstitution (const matrix< T > &theMatrix, const typename parameters::eTriangularType &tType=parameters::Lower) | |
forwardSubstitution (const parameters &par) | |
forwardSubstitution (const forwardSubstitution &other) | |
virtual | ~forwardSubstitution () |
virtual const char * | getTypeName () const |
bool | apply (vector< T > &b) const |
bool | apply (const vector< T > &b, vector< T > &x) const |
bool | apply (const matrix< T > &theMatrix, vector< T > &b, const typename parameters::eTriangularType &tType) const |
bool | apply (const matrix< T > &theMatrix, const vector< T > &b, vector< T > &x, const typename parameters::eTriangularType &tType) const |
bool | apply (matrix< T > &b) const |
bool | apply (const matrix< T > &b, matrix< T > &x) const |
bool | apply (const matrix< T > &theMatrix, matrix< T > &b, const typename parameters::eTriangularType &tType) const |
bool | apply (const matrix< T > &theMatrix, const matrix< T > &b, matrix< T > &x, const typename parameters::eTriangularType &tType) const |
forwardSubstitution & | copy (const forwardSubstitution &other) |
forwardSubstitution & | operator= (const forwardSubstitution &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
Forward substitution.
Let L be a lower triangular matrix and U an upper triangular matrix. Forward substitution solves the following linear equation systems for x:
L*x=b or x*U=b
In the first case, x and b are column vectors, in the latter case they are row vectors. The data matrix can be given to the functor via the parameters or directly in the apply methods. There are also apply methods that calculate the forward substitution for multiple right-sides b. The vectors are treated as before, ie they are in columns for the first case and in rows for the second.
Note that the column vector matrix will be transposed twice and thus takes longer to compute, try to use the vector-apply instead.
lti::forwardSubstitution< T >::forwardSubstitution | ( | ) |
default constructor
lti::forwardSubstitution< T >::forwardSubstitution | ( | const matrix< T > & | theMatrix, | |
const typename parameters::eTriangularType & | tType = parameters::Lower | |||
) |
constructor, sets the data matrix and its triangular type in the parameters.
Note: Using this constructor, the data matrix is copied twice (Once to internally put it into a parameters object and then when setting the parameters). It can be better to let parameters::theMatrix use the data of some matrix you have:
matrix<double> myData; //let this contain the data
forwardSubstitution<double>::parameters param;
param.theMatrix.useExternData(myData.rows(),myData.columns(),&myData.at(0,0))
forwardSubstitution<double> mySubst(param);
The fastest method is to use one of the apply-methods where the data matrix is an argument.
theMatrix | the data matrix | |
tType | triangularType of theMatrix |
lti::forwardSubstitution< T >::forwardSubstitution | ( | const parameters & | par | ) |
Construct a functor using the given parameters.
lti::forwardSubstitution< T >::forwardSubstitution | ( | const forwardSubstitution< T > & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::forwardSubstitution< T >::~forwardSubstitution | ( | ) | [virtual] |
destructor
bool lti::forwardSubstitution< T >::apply | ( | const matrix< T > & | theMatrix, | |
const matrix< T > & | b, | |||
matrix< T > & | x, | |||
const typename parameters::eTriangularType & | tType | |||
) | const |
Performs forward substitution with unknowns X.
L*X=B if theMatrix is lower triagonal and X*U=B if theMatrix is upper triagonal. In the first case X and B contain the vectors in colums, in the latter case in rows.
theMatrix | data matrix (L or U) | |
b | the right side of the forward substitution. The result will be left here too. | |
x | the result | |
tType | defines whether theMatrix is lower or upper triangular |
bool lti::forwardSubstitution< T >::apply | ( | const matrix< T > & | theMatrix, | |
matrix< T > & | b, | |||
const typename parameters::eTriangularType & | tType | |||
) | const |
Performs forward substitution with unknowns X.
L*X=B if theMatrix is lower triagonal and X*U=B if theMatrix is upper triagonal. In the first case X and B contain the vectors in colums, in the latter case in rows. The result x is left in b.
theMatrix | data matrix (L or U) | |
b | the right side of the forward substitution. The result will be left here too. | |
tType | defines whether theMatrix is lower or upper triangular |
bool lti::forwardSubstitution< T >::apply | ( | const matrix< T > & | b, | |
matrix< T > & | x | |||
) | const |
Performs forward substitution with unknowns X.
L*X=B if theMatrix is lower triagonal and X*U=B if theMatrix is upper triagonal. In the first case X and B contain the vectors in colums, in the latter case in rows. The data matrix in the parameters is used.
b | the right side of the forward substitution. | |
x | the result |
bool lti::forwardSubstitution< T >::apply | ( | matrix< T > & | b | ) | const |
Performs forward substitution with unknowns X.
L*X=B if theMatrix is lower triagonal and X*U=B if theMatrix is upper triagonal. In the first case X and B contain the vectors in colums, in the latter case in rows. The result x is left in b. The matrix in the parameters is used.
b | the right side of the forward substitution. The result will be left here too. |
bool lti::forwardSubstitution< T >::apply | ( | const matrix< T > & | theMatrix, | |
const vector< T > & | b, | |||
vector< T > & | x, | |||
const typename parameters::eTriangularType & | tType | |||
) | const |
Performs forward substitution with unknown x.
L*x=b if theMatrix is lower triagonal and x*U=b if theMatrix is upper triagonal.
theMatrix | data matrix (L or U) | |
b | the right side of the forward substitution. The result will be left here too. | |
x | the result. | |
tType | defines whether theMatrix is lower or upper triangular |
bool lti::forwardSubstitution< T >::apply | ( | const matrix< T > & | theMatrix, | |
vector< T > & | b, | |||
const typename parameters::eTriangularType & | tType | |||
) | const |
Performs forward substitution with unknown x.
L*x=b if theMatrix is lower triagonal and x*U=b if theMatrix is upper triagonal. The result x is left in b.
theMatrix | data matrix (L or U) | |
b | the right side of the forward substitution. The result will be left here too. | |
tType | defines whether theMatrix is lower or upper triangular |
bool lti::forwardSubstitution< T >::apply | ( | const vector< T > & | b, | |
vector< T > & | x | |||
) | const |
Performs forward substitution with unknown x.
L*x=b if theMatrix is lower triagonal and x*U=b if theMatrix is upper triagonal. The matrix in the parameters is used.
b | the right side of the forward substitution. | |
x | the result. |
bool lti::forwardSubstitution< T >::apply | ( | vector< T > & | b | ) | const |
Performs forward substitution with unknown x.
L*x=b if theMatrix is lower triagonal and x*U=b if theMatrix is upper triagonal. The result x is left in b. The matrix in the parameters is used.
b | the right side of the forward substitution. The result will be left here too. |
virtual functor* lti::forwardSubstitution< T >::clone | ( | ) | const [virtual] |
returns a pointer to a clone of this functor.
Implements lti::functor.
forwardSubstitution& lti::forwardSubstitution< T >::copy | ( | const forwardSubstitution< T > & | other | ) |
copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::functor.
const parameters& lti::forwardSubstitution< T >::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::functor.
virtual const char* lti::forwardSubstitution< T >::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("forwardSubstitution")
Reimplemented from lti::linearAlgebraFunctor.
forwardSubstitution& lti::forwardSubstitution< T >::operator= | ( | const forwardSubstitution< T > & | other | ) |