>
>#include <rw/math/genmat.h> // RWGenMat<T>, class T general #include <rw/fsymfct.h> // FloatSymFact, float symmetric #include <rw/dsymfct.h> // DoubleSymFact, double symmetric #include <rw/csymfct.h> // DComplexSymFact, complex symmetric #include <rw/chermfct.h> // DComplexHermFact, complex Hermitian #include <rw/fpdfct.h> // FloatPDFact, float positive definite #include <rw/dpdfct.h> // DoublePDFact, double positive definite #include <rw/cpdfct.h> // DComplexPDFact, complex positive
// definite #include <rw/fbandfct.h> // FloatBandFact, float band #include <rw/dbandfct.h> // DoubleBandFact, double band #include <rw/cbandfct.h> // DComplexBandFact, complex band #include <rw/fpdbdfct.h> // FloatPDBandFact, float positive
// definite band #include <rw/dpdbdfct.h> // DoublePDBandFact, double positive
// definite band #include <rw/cpdbdfct.h> // DComplexPDBandFact, complex positive
// definite band #include <rw/ftrdgfct.h> // FloatTriDiagFact, float tridiagonal #include <rw/dtrdgfct.h> // DoubleTriDiagFact, double tridiagonal #include <rw/ctrdgfct.h> // DComplexTriDiagFact, complex
// tridiagonal #include <rw/fpdtdfct.h> // FloatPDTriDiagFact, float pos def
// tridiagonal #include <rw/dpdtdfct.h> // DoublePDTriDiagFact, double pos def
// tridiagonal #include <rw/cpdtdfct.h> // DComplexPDTriDiagFact, complex pos def
// tridiagonal RWGenFact<double> LU(A); // A is a RWGenMat<double> DoubleSymFact LU2(B); // B is a DoubleSymMat DComplexHermFact LU3(C); // C is a DComplexHermMat DoublePDFact LU4(D); // D is a DoublePDMat DoubleBandFact LU5(E); // E is a DoubleBandMat DoubleTriDiagFact LU6(F); // F is a DoubleTriDiagMat DoublePDTriDiagFact LU7(G); // G is a DoublePDTriDiagMat
The classes {TYPE}{SHAPE}Fact encapsulate factorizations. A factorization is a representation of a matrix that can be used to efficiently solve systems of equations, and to compute the inverse, determinant, and condition number of a matrix. The classes RWGenFact<T>, {TYPE}SymFact, {TYPE}HermFact, {TYPE}BandFact, and {TYPE}TriDiagFact encapsulate factorizations of general square, symmetric, Hermitian, banded, and tridiagonal matrices. Provided the matrix being factored is nonsingular, the resulting factorization can always be used to solve a system of equations.
The classes {TYPE}PDFact, {TYPE}PDBandFact, and {TYPE}PDTriDiagFact encapsulate factorizations of positive definite symmetric matrices, which are Hermitians in the complex case. These classes produce a valid factorization only if the matrix being factored is positive definite. If the matrix is not positive definite, attempting to use the factorization to solve a system of equations results in an exception being thrown. To test if the factorization is valid, use the good or fail member functions.
>#include <iostream.h> #include <rw/dgenfct.h> main() { // Read in a matrix and a right-hand side and>
// print the solution RWGenMat<double> A; RWMathVec<double> b; cin >> A >> b; RWGenFact<double> LU(A); if (LU.good()) { cout << "solution is " << solve(LU,b) << endl; } else { cout << "Could not factor A, perhaps it is singular" << endl; } }
RWGenFact<T>(); FloatSymFact(); DoubleSymFact(); DComplexSymFact(); DComplexHermFact(); FloatPDFact(); DoublePDFact(); DComplexPDFact(); FloatBandFact(); DoubleBandFact(); DComplexBandFact(); FloatPDBandFact(); DoublePDBandFact(); DComplexPDBandFact(); FloatTriDiagFact(); DoubleTriDiagFact(); DComplexTriDiagFact(); FloatPDTriDiagFact(); DoublePDTriDiagFact(); DComplexPDTriDiagFact();
Default constructor. Builds a factorization of a 0 x 0 matrix. You use the member function factor to fill in the factorization.
RWGenFact<T>(const RWGenMat<T>& A, RWBoolean ec=TRUE); FloatSymFact(const FloatSymMat& A, RWBoolean ec=TRUE); DoubleSymFact(const DoubleSymMat& A, RWBoolean ec=TRUE); DComplexSymFact(const DComplexSymMat& A, RWBoolean ec=TRUE); DComplexHermFact(const DComplexHermMat& A, RWBoolean ec=TRUE); FloatPDFact(const FloatSymMat& A, RWBoolean ec=TRUE); DoublePDFact(const DoubleSymMat& A, RWBoolean ec=TRUE); DComplexPDFact(const DComplexHermMat& A, RWBoolean ec=TRUE); FloatBandFact(const FloatBandMat& A, RWBoolean ec=TRUE); DoubleBandFact(const DoubleBandMat& A, RWBoolean ec=TRUE); DComplexBandFact(const DComplexBandMat& A, RWBoolean ec=TRUE); FloatPDBandFact(const FloatBandMat& A, RWBoolean ec=TRUE); DoublePDBandFact(const DoubleBandMat& A, RWBoolean ec=TRUE); DComplexPDBandFact(const DComplexHermMat& A, RWBoolean ec=TRUE); FloatTriDiagFact(const FloatTriDiagMat& A, RWBoolean ec=TRUE); DoubleTriDiagFact(const DoubleTriDiagMat& A, RWBoolean ec=TRUE); DComplexTriDiagFact(const DComplexTriDiagMat& A, RWBoolean ec=TRUE); FloatPDTriDiagFact(const FloatTriDiagMat& A, RWBoolean ec=TRUE); DoublePDTriDiagFact(const DoubleTriDiagMat& A, RWBoolean ec=TRUE); DComplexPDTriDiagFact(const DComplexTriDiagMat& A, RWBoolean ec=TRUE);
Constructs a factorization of the matrix A. This factorization can be used to solve systems of equations, and to calculate inverses and determinants. If the parameter ec is TRUE, you can use the function condition to obtain an estimate of the condition number of the matrix. Setting ec to FALSE can save some computation if the condition number is not needed.
unsigned RWGenFact<T>::cols() const; unsigned FloatSymFact::cols() const; unsigned DoubleSymFact::cols() const; unsigned DComplexSymFact::cols() const; unsigned DComplexHermFact::cols() const; unsigned FloatPDFact::cols() const; unsigned DoublePDFact::cols() const; unsigned DComplexPDFact::cols() const; unsigned FloatBandFact::cols() const; unsigned DoubleBandFact::cols() const; unsigned DComplexBandFact::cols() const; unsigned FloatPDBandFact::cols() const; unsigned DoublePDBandFact::cols() const; unsigned DComplexPDBandFact::cols() const; unsigned FloatTriDiagFact::cols() const; unsigned DoubleTriDiagFact::cols() const; unsigned DComplexTriDiagFact::cols() const; unsigned FloatPDTriDiagFact::cols() const; unsigned DoublePDTriDiagFact::cols() const; unsigned DComplexPDTriDiagFact::cols() const;
Returns the number of columns in the matrix represented by this factorization.
void RWGenFact<T>::factor(const RWGenMat<T>& A,
RWBoolean void ec=TRUE); void FloatSymFact::factor(const FloatSymMat& A,
RWBoolean ec=TRUE); void DoubleSymFact::factor(const DoubleSymMat& A,
RWBoolean ec=TRUE); void DComplexSymFact::factor(const DComplexSymMat& A,
RWBoolean void ec=TRUE); void DComplexHermFact::factor(const DComplexHermMat& A,
RWBoolean void ec=TRUE); void FloatPDFact::factor(const FloatSymMat& A,
RWBoolean ec=TRUE); void DoublePDFact::factor(const DoubleSymMat& A,
RWBoolean ec=TRUE); void DComplexPDFact::factor(const DComplexHermMat& A,
RWBoolean void ec=TRUE); void FloatBandFact::factor(const FloatBandMat& A,
RWBoolean ec=TRUE); void DoubleBandFact::factor(const DoubleBandMat& A,
RWBoolean void ec=TRUE); void DComplexBandFact::factor(const DComplexBandMat& A,
RWBoolean void ec=TRUE); void FloatPDBandFact::factor(const FloatBandMat& A,
RWBoolean void ec=TRUE); void DoublePDBandFact::factor(const DoubleBandMat& A,
RWBoolean void ec=TRUE); void DComplexPDBandFact::factor(const DComplexHermMat& A,
RWBoolean void ec=TRUE); void FloatTriDiagFact::factor(const FloatTriDiagMat& A,
RWBoolean void ec=TRUE); void DoubleTriDiagFact::factor(const DoubleTriDiagMat& A,
RWBoolean void ec=TRUE); void DComplexTriDiagFact::factor(const DComplexTriDiagMat& A,
RWBoolvoid ean ec=TRUE); void FloatPDTriDiagFact::factor(const FloatTriDiagMat& A,
RWBoolean void ec=TRUE); void DoublePDTriDiagFact::factor(const DoubleTriDiagMat& A,
RWBoolean void ec=TRUE); void DComplexPDTriDiagFact::factor(const
DComplexTriDiagMat& A, void RWBoolean ec=TRUE);
Factors a matrix. Calling factor replaces the current factorization with the factorization of the matrix A. This is commonly used to initialize a factorization constructed with the default (no arguments) constructor.
RWBoolean RWGenFact<T>::fail() const; RWBoolean FloatSymFact::fail() const; RWBoolean DoubleSymFact::fail() const; RWBoolean DComplexSymFact::fail() const; RWBoolean DComplexHermFact::fail() const; RWBoolean FloatPDFact::fail() const; RWBoolean DoublePDFact::fail() const; RWBoolean DComplexPDFact::fail() const; RWBoolean FloatBandFact::fail() const; RWBoolean DoubleBandFact::fail() const; RWBoolean DComplexBandFact::fail() const; RWBoolean FloatPDBandFact::fail() const; RWBoolean DoublePDBandFact::fail() const; RWBoolean DComplexPDBandFact::fail() const; RWBoolean FloatTriDiagFact::fail() const; RWBoolean DoubleTriDiagFact::fail() const; RWBoolean DComplexTriDiagFact::fail() const; RWBoolean FloatPDTriDiagFact::fail() const; RWBoolean DoublePDTriDiagFact::fail() const; RWBoolean DComplexPDTriDiagFact::fail() const; RWBoolean FloatGenFact::good() const; RWBoolean DoubleGenFact::good() const; RWBoolean DComplexGenFact::good() const; RWBoolean FloatSymFact::good() const; RWBoolean DoubleSymFact::good() const; RWBoolean DComplexSymFact::good() const; RWBoolean DComplexHermFact::good() const; RWBoolean FloatPDFact::good() const; RWBoolean DoublePDFact::good() const; RWBoolean DComplexPDFact::good() const; RWBoolean FloatBandFact::good() const; RWBoolean DoubleBandFact::good() const; RWBoolean DComplexBandFact::good() const; RWBoolean FloatPDBandFact::good() const; RWBoolean DoublePDBandFact::good() const; RWBoolean DComplexPDBandFact::good() const; RWBoolean FloatTriDiagFact::good() const; RWBoolean DoubleTriDiagFact::good() const; RWBoolean DComplexTriDiagFact::good() const; RWBoolean FloatPDTriDiagFact::good() const; RWBoolean DoublePDTriDiagFact::good() const; RWBoolean DComplexPDTriDiagFact::good() const;
Checks whether the factorization is successfully constructed. If good returns FALSE or fail returns TRUE, attempting to use the factorization to solve a system of equations results in an exception being thrown.
RWBoolean FloatPDFact::isPD() const; RWBoolean DoublePDFact::isPD() const; RWBoolean DComplexPDFact::isPD() const; RWBoolean FloatPDBandFact::isPD() const; RWBoolean DoublePDBandFact::isPD() const; RWBoolean DComplexPDBandFact::isPD() const; RWBoolean FloatPDTriDiagFact::isPD() const; RWBoolean DoublePDTriDiagFact::isPD() const; RWBoolean DComplexPDTriDiagFact::isPD() const;
Tests if the matrix is positive definite. If the matrix is not positive definite, the factorization is not complete and you cannot use the factorization to solve systems of equations.
RWBoolean RWGenFact<T>::isSingular() const; RWBoolean DoubleGenFact::isSingular() const; RWBoolean DComplexGenFact::isSingular() const; RWBoolean FloatSymFact::isSingular() const; RWBoolean DoubleSymFact::isSingular() const; RWBoolean DComplexSymFact::isSingular() const; RWBoolean DComplexHermFact::isSingular() const; RWBoolean FloatPDFact::isSingular() const; RWBoolean DoublePDFact::isSingular() const; RWBoolean DComplexPDFact::isSingular() const; RWBoolean FloatBandFact::isSingular() const; RWBoolean DoubleBandFact::isSingular() const; RWBoolean DComplexBandFact::isSingular() const; RWBoolean FloatPDBandFact::isSingular() const; RWBoolean DoublePDBandFact::isSingular() const; RWBoolean DComplexPDBandFact::isSingular() const; RWBoolean FloatTriDiagFact::isSingular() const; RWBoolean DoubleTriDiagFact::isSingular() const; RWBoolean DComplexTriDiagFact::isSingular() const; RWBoolean FloatPDTriDiagFact::isSingular() const; RWBoolean DoublePDTriDiagFact::isSingular() const; RWBoolean DComplexPDTriDiagFact::isSingular() const;
Tests if the matrix is singular to within machine precision. If the factorization is a positive definite type and the matrix that was factored is not actually positive definite, then isSingular may return TRUE regardless of whether or not the matrix is actually singular.
unsigned RWGenFact<T>::rows() const; unsigned FloatSymFact::rows() const; unsigned DoubleSymFact::rows() const; unsigned DComplexSymFact::rows() const; unsigned DComplexHermFact::rows() const; unsigned FloatPDFact::rows() const; unsigned DoublePDFact::rows() const; unsigned DComplexPDFact::rows() const; unsigned FloatBandFact::rows() const; unsigned DoubleBandFact::rows() const; unsigned DComplexBandFact::rows() const; unsigned FloatPDBandFact::rows() const; unsigned DoublePDBandFact::rows() const; unsigned DComplexPDBandFact::rows() const; unsigned FloatTriDiagFact::rows() const; unsigned DoubleTriDiagFact::rows() const; unsigned DComplexTriDiagFact::rows() const; unsigned FloatPDTriDiagFact::rows() const; unsigned DoublePDTriDiagFact::rows() const; unsigned DComplexPDTriDiagFact::rows() const;
Returns the number of rows in the matrix represented by this factorization.
float condition(const FloatSymFact& A); double condition(const DoubleSymFact& A); double condition(const DComplexSymFact& A); double condition(const DComplexHermFact& A); float condition(const FloatPDFact& A); double condition(const DoublePDFact& A); double condition(const DComplexPDFact& A); float condition(const FloatBandFact& A); double condition(const DoubleBandFact& A); double condition(const DComplexBandFact& A); float condition(const FloatPDBandFact& A); double condition(const DoublePDBandFact& A); double condition(const DComplexPDBandFact& A); float condition(const FloatTriDiagFact& A); double condition(const DoubleTriDiagFact& A); double condition(const DComplexTriDiagFact& A); float condition(const FloatPDTriDiagFact& A); double condition(const DoublePDTriDiagFact& A); double condition(const DComplexPDTriDiagFact& A); rw_numeric_traits<T>::norm_type condition(const RWGenFact<T>& A);
Calculates the reciprocal condition number of the matrix represented by this factorization. If this number is near 0, the matrix is ill-conditioned and solutions to systems of equations computed using this factorization may not be accurate. If the number is near 1, the matrix is well-conditioned. For the condition number to be computed, the norm of the matrix must be computed at the time the factorization is constructed. If you set the optional boolean parameter in the constructor or the factor member function to FALSE, calling condition generates an exception.
T determinant(const RWGenFact<T>& A); float determinant(const FloatSymFact& A); double determinant(const DoubleSymFact& A); DComplex determinant(const DComplexSymFact& A); DComplex determinant(const DComplexHermFact& A); float determinant(const FloatPDFact& A); double determinant(const DoublePDFact& A); DComplex determinant(const DComplexPDFact& A); float determinant(const FloatBandFact& A); double determinant(const DoubleBandFact& A); DComplex determinant(const DComplexBandFact& A); float determinant(const FloatPDBandFact& A); double determinant(const DoublePDBandFact& A); DComplex determinant(const DComplexPDBandFact& A); float determinant(const FloatTriDiagFact& A); double determinant(const DoubleTriDiagFact& A); DComplex determinant(const DComplexTriDiagFact& A); float determinant(const FloatPDTriDiagFact& A); double determinant(const DoublePDTriDiagFact& A); DComplex determinant(const DComplexPDTriDiagFact& A);
Calculates the determinant of the matrix represented by this factorization.
RWGenMat<T> inverse(const RWGenFact<T>&); RWGenMat<double> inverse(const DoubleGenFact&); RWGenMat<DComplex> inverse(const DComplexGenFact&); FloatSymMat inverse(const FloatSymFact&); DoubleSymMat inverse(const DoubleSymFact&); DComplexSymMat inverse(const DComplexSymFact&); DComplexHermMat inverse(const DComplexHermFact&); FloatSymMat inverse(const FloatPDFact&); DoubleSymMat inverse(const DoublePDFact&); DComplexHermMat inverse(const DComplexPDFact&);
Computes the inverse of the matrix represented by this factorization. Although matrix inverses are very useful in theoretical analysis, they are rarely necessary in implementation. A factorization is nearly always as useful as the actual inverse, and can be constructed at far less cost.
RWMathVec<T> solve(const RWGenFact<T>& A, const RWMathVec<T>& b); RWMathVec<float> solve(const FloatSymFact& A, const RWMathVec<float>& b); RWMathVec<double> solve(const DoubleSymFact& A, const RWMathVec<double>& b); RWMathVec<DComplex> solve(const DComplexSymFact& A, const RWMathVec<DComplex>&); RWMathVec<DComplex> solve(const DComplexHermFact& A, const RWMathVec<DComplex>&); RWMathVec<float> solve(const FloatPDFact& A, const RWMathVec<float>& b); RWMathVec<double> solve(const DoublePDFact& A, const RWMathVec<double>& b); RWMathVec<DComplex> solve(const DComplexPDFact& A, const RWMathVec<DComplex>& b); RWMathVec<float> solve(const FloatBandFact& A, const RWMathVec<float>& b); RWMathVec<double> solve(const DoubleBandFact& A, const RWMathVec<double>& b); RWMathVec<DComplex> solve(const DComplexBandFact& A, const RWMathVec<DComplex>&); RWMathVec<float> solve(const FloatPDBandFact& A, const RWMathVec<float>& b); RWMathVec<double> solve(const DoublePDBandFact& A, const RWMathVec<double>& b); RWMathVec<DComplex> solve(const DComplexPDBandFact&, const RWMathVec<DComplex>&); RWMathVec<float> solve(const FloatTriDiagFact& A, const RWMathVec<float>& b); RWMathVec<double> solve(const DoubleTriDiagFact& A, const RWMathVec<double>&); RWMathVec<DComplex> solve(const DComplexTriDiagFact&, const RWMathVec<DComplex>&); RWMathVec<float> solve(const FloatPDTriDiagFact& A, const RWMathVec<float>&); RWMathVec<double> solve(const DoublePDTriDiagFact&, const RWMathVec<double>&); RWMathVec<DComplex> solve(const DComplexPDTriDiagFact& A, const RWMathVec<DComplex>& b);
Solves a system of equations. Returns the vector x, which satisfies Ax=b, where A is the matrix represented by the factorization. It is wise to call one of the member functions good or fail to make sure that the factorization was successfully constructed.
RWGenMat<T> solve(const RWGenFact<T>& A, const RWGenMat<T>& B); RWGenMat<float> solve(const FloatSymFact& A, const RWGenMat<float>& B); RWGenMat<double> solve(const DoubleSymFact& A, const RWGenMat<double>& B); RWGenMat<DComplex> solve(const DComplexSymFact&, const RWGenMat<DComplex>&); RWGenMat<DComplex> solve(const DComplexHermFact&, const RWGenMat<DComplex>&); RWGenMat<float> solve(const FloatPDFact& A, const RWGenMat<float>& B); RWGenMat<double> solve(const DoublePDFact& A, const RWGenMat<double>& B); RWGenMat<DComplex> solve(const DComplexPDFact&, const RWGenMat<DComplex>&); RWGenMat<float> solve(const FloatBandFact& A, const RWGenMat<float>& B); RWGenMat<double> solve(const DoubleBandFact& A, const RWGenMat<double>&); RWGenMat<DComplex> solve(const DComplexBandFact&, const RWGenMat<DComplex>&); RWGenMat<float> solve(const FloatPDBandFact& A, const RWGenMat<float>&); RWGenMat<double> solve(const DoublePDBandFact&, const RWGenMat<double>&); RWGenMat<DComplex> solve(const DComplexPDBandFact& A, const RWGenMat<DComplex>& B); RWGenMat<float> solve(const FloatTriDiagFact& A, const RWGenMat<float>&); RWGenMat<double> solve(const DoubleTriDiagFact&, const RWGenMat<double>&); RWGenMat<DComplex> solve(const DComplexTriDiagFact& A, const RWGenMat<DComplex>& B); RWGenMat<float> solve(const FloatPDTriDiagFact& A, const RWGenMat<float>& B); RWGenMat<double> solve(const DoublePDTriDiagFact& A, const RWGenMat<double>& B); RWGenMat<DComplex> solve(const DComplexPDTriDiagFact& A, const RWGenMat<DComplex>& B);
Solves a system of equations. Returns the matrix X, which satisfies AX=B, where A is the matrix represented by the factorization. It is wise to call one of the member functions good or fail to make sure that the factorization was successfully constructed.
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.