Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

TLUDecomp Class Template Reference

#include <Ludecomp.hpp>

Inheritance diagram for TLUDecomp::

smatrix List of all members.

Public Methods

 TLUDecomp (const smatrix< t > &m, bool bWithPartialPivot)
 TLUDecomp (const t *d, size_t iDim, size_t jDim, bool bWithPartialPivot)
 TLUDecomp ()
bool Decompose (const smatrix< t > &m, bool bWithPartialPivot)
void FwdElim (smatrix< t > &c) const
void BackElim (smatrix< t > &c) const
bool Decompose (bool bWithPartialPivot)
smatrix< t > Solve (const smatrix< t > &m) const
smatrix< t > Inverse () const
smatrix< t > L () const
smatrix< t > U () const
smatrix< t > P () const

Protected Attributes

smatrix< t > pivots
bool bDecomposed

template<class t>
class TLUDecomp< t >


Constructor & Destructor Documentation

template<class t>
TLUDecomp< t >::TLUDecomp const smatrix< t > &    m,
bool    bWithPartialPivot
[inline]
 

Definition at line 10 of file Ludecomp.hpp.

00010                                                            : 
00011         smatrix<t>(m)
00012     {
00013         bDecomposed = false;
00014         if(Decompose(bWithPartialPivot) == false)
00015         {
00016             pivots = smatrix<t>();
00017             *this = TLUDecomp<t>();
00018         }
00019     }

template<class t>
TLUDecomp< t >::TLUDecomp const t *    d,
size_t    iDim,
size_t    jDim,
bool    bWithPartialPivot
[inline]
 

Definition at line 20 of file Ludecomp.hpp.

00021                                 : smatrix<t> (d, iDim, jDim)
00022     {
00023         bDecomposed = false;
00024         if(Decompose(bWithPartialPivot) == false)
00025         {
00026             pivots = smatrix<t>();
00027             *this = TLUDecomp<t>();
00028         }
00029     }

template<class t>
TLUDecomp< t >::TLUDecomp   [inline]
 

Definition at line 30 of file Ludecomp.hpp.

00030 { bDecomposed = false; }


Member Function Documentation

template<class t>
void TLUDecomp< t >::BackElim smatrix< t > &    c const [inline]
 

Definition at line 56 of file Ludecomp.hpp.

00057     {
00058         for(size_t k = iDim; k >= 1; k--)
00059         {
00060             t Diag = t(-1.0) / Coef(k, k);
00061             const_iterator i = IterForCol(k);
00062             while(Index(i) < k)
00063             {
00064                 t Scaler = Coef(i) * Diag;
00065                 size_t r = Index(i++);
00066                 c.row(r) += c.row(k) * Scaler;
00067             }
00068             c.row(k) *= -Diag;
00069         }
00070     }

template<class t>
bool TLUDecomp< t >::Decompose bool    bWithPartialPivot [inline]
 

Definition at line 71 of file Ludecomp.hpp.

00072     {
00073         if(bDecomposed) return(true);
00074         if(iDim != jDim) return(false);
00075         pivots = smIdentity<t>(iDim);
00076         for(size_t k = 1; k < iDim; k++)
00077         {
00078             t Diag;
00079             if(!GetDiag(k, Diag, bWithPartialPivot, &pivots)) 
00080                 return(false);
00081             Diag = t(-1.0) / Diag;
00082             iterator i = IterForCol(k, k + 1);
00083             while(i != EndOfCol(k))
00084             {
00085                 t Scaler = Coef(i) * Diag;
00086                 size_t r = Index(i++);
00087                 row(r) += row(k, rng(k + 1, jDim)) * Scaler;
00088                 Coef(r, k) = Scaler;
00089             }
00090         }
00091         t Diag = Coef(k, k);
00092         if(abs(Diag) < epsilon)
00093             return(false);
00094         bDecomposed = true;
00095         return(true);
00096     }

template<class t>
bool TLUDecomp< t >::Decompose const smatrix< t > &    m,
bool    bWithPartialPivot
[inline]
 

Definition at line 31 of file Ludecomp.hpp.

Referenced by TLUDecomp().

00032     {
00033         *this = m;
00034         bDecomposed = false;
00035         if(Decompose(bWithPartialPivot) == false)
00036         {
00037             pivots = smatrix<t>();
00038             *this = TLUDecomp<t>();
00039             return(false);
00040         }
00041         return(true);
00042     }

template<class t>
void TLUDecomp< t >::FwdElim smatrix< t > &    c const [inline]
 

Definition at line 43 of file Ludecomp.hpp.

00044     {
00045         for(size_t k = 1; k < iDim; k++)
00046         {
00047             const_iterator i = IterForCol(k, k + 1);
00048             while(i != EndOfCol(k))
00049             {
00050                 t Scaler = Coef(i);
00051                 size_t r = Index(i++);
00052                 c.row(r) += c.row(k) * Scaler;
00053             }
00054         }
00055     }

template<class t>
smatrix<t> TLUDecomp< t >::Inverse   const [inline]
 

Definition at line 114 of file Ludecomp.hpp.

00115     {
00116         smatrix<t> c(pivots);
00117         if(bDecomposed)
00118         {
00119             FwdElim(c);
00120             BackElim(c);
00121         }
00122         return(c);
00123     }

template<class t>
smatrix<t> TLUDecomp< t >::L   const [inline]
 

Definition at line 124 of file Ludecomp.hpp.

00125     {
00126         smatrix<t> c(iDim, jDim, NZ);
00127         for(size_t r = 1; r <= iDim; r++)
00128         {
00129             c.row(r) = row(r, rng(1, r - 1)) * t(-1);
00130             c.Coef(r, r) = t(1);
00131         }
00132         return(c);
00133     }

template<class t>
smatrix<t> TLUDecomp< t >::P   const [inline]
 

Definition at line 141 of file Ludecomp.hpp.

00142     {
00143         return(pivots);
00144     }

template<class t>
smatrix<t> TLUDecomp< t >::Solve const smatrix< t > &    m const [inline]
 

Definition at line 97 of file Ludecomp.hpp.

Referenced by main().

00098     {
00099         smatrix<t> c(m.iDim, m.jDim, m.NZ);
00100         if(bDecomposed)
00101         {
00102             for(size_t r = 1; r <= iDim; r++)
00103             {
00104                 const_svector_ref &v = m.row(r);
00105                 const_iterator i = pivots.IterForCol(r);
00106                 size_t x = Index(i);
00107                 c.row(x) = v;
00108             }
00109             FwdElim(c);
00110             BackElim(c);
00111         }
00112         return(c);
00113     }

template<class t>
smatrix<t> TLUDecomp< t >::U   const [inline]
 

Definition at line 134 of file Ludecomp.hpp.

00135     {
00136         smatrix<t> c(iDim, jDim, NZ);
00137         for(size_t r = 1; r <= iDim; r++)
00138             c.row(r) = row(r, rng(r, jDim));
00139         return(c);
00140     }


Member Data Documentation

template<class t>
bool TLUDecomp::bDecomposed [protected]
 

Definition at line 7 of file Ludecomp.hpp.

template<class t>
smatrix<t> TLUDecomp::pivots [protected]
 

Definition at line 6 of file Ludecomp.hpp.


The documentation for this class was generated from the following file:
Generated on Sun Oct 14 18:50:19 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001