#include <Smatrix.hpp>
Inheritance diagram for smatrix::

Public Types | |
| typedef map< size_t, size_t >::iterator | iterator |
| typedef map< size_t, size_t >::const_iterator | const_iterator |
| typedef pair< size_t, size_t > | mapping |
Public Methods | |
| virtual | ~smatrix () |
| smatrix () | |
| smatrix (const smatrix< t > &a) | |
| smatrix (const t *d, size_t iDim, size_t jDim) | |
| smatrix (size_t iDim, size_t jDim, size_t MaxNZ) | |
| smatrix< t > & | operator= (const smatrix< t > &a) |
| void | initialize (size_t MaxNZ) |
| void | initialize (size_t iDim, size_t jDim, size_t MaxNZ) |
| void | erase (size_t pos) |
| size_t | SlackSpace () const |
| double | Sparsity () const |
| void | reserve (size_t space) |
| bool | insert (size_t i, size_t j, const t &d, iterator &iIter, iterator &jIter, bool bZeroInsert=false) |
| iterator | insert (size_t i, size_t j, const t &d) |
| iterator | ZeroInsert (size_t i, size_t j) |
| smatrix< t > & | Transpose () |
| t | operator() (size_t i, size_t j) const |
| coefRef | operator() (size_t i, size_t j) |
| void | erase (size_t i, size_t j) |
| t | Coef (size_t i, size_t j) const |
| coefRef | Coef (size_t i, size_t j) |
| t | Coef (const_iterator p) const |
| t & | Coef (const_iterator p) |
| svector_ref | operator() (size_t i, const rng &range) |
| svector_ref | operator() (const rng &range, size_t j) |
| const_svector_ref | operator() (size_t i, const rng &range) const |
| const_svector_ref | operator() (const rng &range, size_t j) const |
| svector_ref | row (size_t i) |
| svector_ref | row (size_t i, const rng &range) |
| svector_ref | col (size_t j) |
| svector_ref | col (const rng &range, size_t j) |
| const_svector_ref | row (size_t i) const |
| const_svector_ref | row (size_t i, const rng &range) const |
| const_svector_ref | col (size_t j) const |
| const_svector_ref | col (const rng &range, size_t j) const |
| iterator | IterFor (size_t n, size_t Start, const vector_map *p) |
| const_iterator | IterFor (size_t n, size_t Start, const vector_map *p) const |
| iterator | EndOf (size_t n, vector_map *p) |
| const_iterator | EndOf (size_t n, const vector_map *p) const |
| iterator | IterForRow (size_t i, size_t jStart=1) |
| const_iterator | IterForRow (size_t i, size_t jStart=1) const |
| const_iterator | EndOfRow (size_t i) const |
| iterator | EndOfRow (size_t i) |
| iterator | IterForCol (size_t j, size_t iStart=1) |
| const_iterator | IterForCol (size_t j, size_t iStart=1) const |
| const_iterator | EndOfCol (size_t j) const |
| iterator | EndOfCol (size_t j) |
| smatrix< t > | operator+ (const smatrix< t > &b) const |
| smatrix< t > | operator- (const smatrix< t > &b) const |
| smatrix< t > | operator * (const smatrix< t > &b) const |
| bool | operator== (const smatrix< t > &b) const |
| bool | operator!= (const const smatrix< t > &b) |
| bool | operator! () |
| void | PivotMap (size_t a, size_t b, vector_map *Source, vector_map &Dest) |
| bool | Pivot (size_t k, size_t &MaxIdx, t &MaxCoef, vector_map *Source, vector_map &Dest) |
| void | PivotRow (size_t k, size_t MaxIdx, smatrix< t > *pMatix=NULL) |
| bool | PivotRow (size_t k, t &MaxCoef, smatrix< t > *pMatix=NULL) |
| void | PivotCol (size_t k, size_t MaxIdx, smatrix< t > *pMatix=NULL) |
| bool | PivotCol (size_t k, t &MaxCoef, smatrix< t > *pMatix=NULL) |
| bool | GetDiag (size_t k, t &Diag, bool bWithPartialPivot=false, smatrix< t > *pMatix=NULL) |
| bool | FwdElim (bool bWithPartialPivot, bool bErase=true) |
| bool | BackElim (bool bErase=true, bool bScaleDiag=true) |
| bool | SolveWithGaussElim (const smatrix< t > &m, bool bWithPartialPivot=true) |
| smatrix< t > | SolveWithGaussElim (bool bWithPartialPivot=true) const |
| t | det (bool bWithPartialPivot) |
| int | lnScaledDet (t &lnScale, bool bWithPartialPivot) |
| int | lnScaledDet (const smatrix< t > &m, t &lnScale, bool bWithPartialPivot) |
| int | lnScaledDet (t &lnScale, bool bWithPartialPivot=true) const |
| bool | FwdElim (smatrix< t > &m, bool bWithPartialPivot) |
| void | RecalcMaxCoef () |
| bool | BackElim (smatrix< t > &m) |
| smatrix< t > | Solve (const smatrix< t > &L, const smatrix< t > &U) const |
| smatrix< t > | Inverse (bool bWithPartialPivot) const |
| t | FrobeniousNormal () const |
| smatrix< t > & | operator *= (const t &d) |
| smatrix< t > | operator * (const t &d) const |
| void | PrintListing (ostream &os) const |
Static Public Methods | |
| template<class ta, class tb> t | svMultiply (const ta &a, const tb &b) |
| size_t | Index (const_iterator p) |
| size_t | Index (iterator p) |
| size_t | CoefPtr (const_iterator p) |
| size_t | CoefPtr (iterator p) |
Public Attributes | |
| vector< t > | e |
| t | epsilon |
| t | maxCoef |
| vector_map * | iMap |
| vector_map * | jMap |
| size_t | iDim |
| size_t | jDim |
| size_t | NZ |
| size_t | FirstBlank |
| size_t | FreeSlots |
| bool | bOddNumPivots |
Static Public Attributes | |
| size_t | PrintWidth = 8 |
| size_t | PrintPrecision = 3 |
|
|||||
|
Definition at line 131 of file Smatrix.hpp. |
|
|||||
|
Definition at line 130 of file Smatrix.hpp. |
|
|||||
|
Definition at line 132 of file Smatrix.hpp. Referenced by PivotMap(), and insert().
|
|
|||||||||
|
Definition at line 134 of file Smatrix.hpp. 00135 {
00136 delete(iMap);
00137 delete(jMap);
00138 }
|
|
|||||||||
|
Definition at line 139 of file Smatrix.hpp. 00139 : iMap(NULL), jMap(NULL), maxCoef(0), 00140 epsilon(0) { initialize(0, 0, 0); } |
|
||||||||||
|
Definition at line 141 of file Smatrix.hpp. |
|
||||||||||||||||||||
|
Definition at line 145 of file Smatrix.hpp. |
|
||||||||||||||||||||
|
Definition at line 157 of file Smatrix.hpp. 00157 : iMap(NULL), jMap(NULL) 00158 { 00159 initialize(iDim, jDim, MaxNZ); 00160 } |
|
||||||||||
|
Definition at line 955 of file Smatrix.hpp. 00956 {
00957 for(size_t k = iDim; k >= 1; k--)
00958 {
00959 t Diag;
00960 if(!GetDiag(k, Diag)) return(false);
00961 Diag = t(-1.0) / Diag;
00962 iterator i = IterForCol(k);
00963 while(Index(i) < k)
00964 {
00965 t Scaler = Coef(i) * Diag;
00966 size_t r = Index(i++);
00967 row(r) += row(k, rng(k, k)) * Scaler;
00968 m.row(r) += m.row(k) * Scaler;
00969 }
00970 m.row(k) *= -Diag;
00971 }
00972 m.RecalcMaxCoef();
00973 return(true);
00974 }
|
|
||||||||||||||||
|
Definition at line 850 of file Smatrix.hpp. Referenced by Inverse(), TLUDecomp::Inverse(), Solve(), TLUDecomp::Solve(), and SolveWithGaussElim().
00851 {
00852 for(size_t k = iDim; k >= 1; k--)
00853 {
00854 t Diag;
00855 if(!GetDiag(k, Diag)) return(false);
00856 Diag = t(-1.0) / Diag;
00857 iterator i = IterForCol(k);
00858 while(Index(i) < k)
00859 {
00860 t Scaler = Coef(i) * Diag;
00861 size_t r = Index(i++);
00862 row(r) += row(k) * Scaler;
00863 if(bErase) erase(r, k);
00864 }
00865 if(bScaleDiag) row(k) *= -Diag;
00866 }
00867 return(true);
00868 }
|
|
||||||||||
|
Definition at line 596 of file Smatrix.hpp. 00596 { return(e[p->second]); }
|
|
||||||||||
|
Definition at line 595 of file Smatrix.hpp. 00595 { return(e[p->second]); }
|
|
||||||||||||||||
|
Definition at line 594 of file Smatrix.hpp. 00594 { return((*this)(i, j)); }
|
|
||||||||||||||||
|
Definition at line 593 of file Smatrix.hpp. Referenced by BackElim(), TLUDecomp::BackElim(), TLUDecomp::Decompose(), FwdElim(), TLUDecomp::FwdElim(), GetDiag(), TLUDecomp::L(), Pivot(), det(), and svMultiply().
00593 { return((*this)(i, j)); }
|
|
||||||||||
|
Definition at line 600 of file Smatrix.hpp. 00600 { return(p->second); }
|
|
||||||||||
|
Definition at line 599 of file Smatrix.hpp. Referenced by PivotMap().
00599 { return(p->second); }
|
|
||||||||||||||||
|
Definition at line 643 of file Smatrix.hpp. 00644 {
00645 const map<size_t, size_t> *Map = (n > p->size() ? (*p)[0] : (*p)[n]);
00646 return(Map->end());
00647 }
|
|
||||||||||||||||
|
Definition at line 638 of file Smatrix.hpp. Referenced by EndOfCol(), EndOfRow(), and PivotMap().
00639 {
00640 map<size_t, size_t> *Map = (n > p->size() ? (*p)[0] : (*p)[n]);
00641 return(Map->end());
00642 }
|
|
||||||||||
|
Definition at line 662 of file Smatrix.hpp. 00663 { return(EndOf(j, jMap)); }
|
|
||||||||||
|
Definition at line 660 of file Smatrix.hpp. Referenced by TLUDecomp::Decompose(), FwdElim(), TLUDecomp::FwdElim(), and PrintListing().
00661 { return(EndOf(j, jMap)); }
|
|
||||||||||
|
Definition at line 654 of file Smatrix.hpp. |
|
||||||||||
|
Definition at line 652 of file Smatrix.hpp. Referenced by PrintListing(), and RecalcMaxCoef().
|
|
|||||||||
|
Definition at line 1000 of file Smatrix.hpp. |
|
||||||||||||||||
|
Definition at line 923 of file Smatrix.hpp. 00924 {
00925 for(size_t k = 1; k < iDim; k++)
00926 {
00927 t Diag;
00928 if(!GetDiag(k, Diag, bWithPartialPivot, &m)) return(false);
00929 Diag = t(-1.0) / Diag;
00930 iterator i = IterForCol(k, k + 1);
00931 while(i != EndOfCol(k))
00932 {
00933 t Scaler = Coef(i) * Diag;
00934 size_t r = Index(i++);
00935 row(r) += row(k, rng(k + 1, jDim)) * Scaler;
00936 m.row(r) += m.row(k) * Scaler;
00937 }
00938 }
00939 t Diag = Coef(k, k);
00940 if(abs(Diag) < epsilon)
00941 return(false);
00942 return(true);
00943 }
|
|
||||||||||||||||
|
Definition at line 829 of file Smatrix.hpp. Referenced by Inverse(), TLUDecomp::Inverse(), Solve(), TLUDecomp::Solve(), SolveWithGaussElim(), det(), and lnScaledDet().
00830 {
00831 for(size_t k = 1; k < iDim; k++)
00832 {
00833 t Diag;
00834 if(!GetDiag(k, Diag, bWithPartialPivot)) return(false);
00835 Diag = t(-1.0) / Diag;
00836 iterator i = IterForCol(k, k + 1);
00837 while(i != EndOfCol(k))
00838 {
00839 t Scaler = Coef(i) * Diag;
00840 size_t r = Index(i++);
00841 row(r) += row(k, rng(k + 1, jDim)) * Scaler;
00842 if(bErase) erase(r, k);
00843 }
00844 }
00845 t Diag = Coef(k, k);
00846 if(abs(Diag) < epsilon)
00847 return(false);
00848 return(true);
00849 }
|
|
||||||||||||||||||||||||
|
Definition at line 816 of file Smatrix.hpp. Referenced by BackElim(), TLUDecomp::Decompose(), FwdElim(), and lnScaledDet().
|
|
||||||||||
|
Definition at line 598 of file Smatrix.hpp. 00598 { return(p->first); }
|
|
||||||||||
|
Definition at line 597 of file Smatrix.hpp. Referenced by BackElim(), TLUDecomp::BackElim(), TLUDecomp::Decompose(), FwdElim(), TLUDecomp::FwdElim(), Pivot(), PivotMap(), TLUDecomp::Solve(), and svMultiply().
00597 { return(p->first); }
|
|
||||||||||
|
Definition at line 987 of file Smatrix.hpp. 00988 {
00989 smIdentity<t> c(iDim);
00990 c.epsilon = epsilon;
00991 smatrix<t> m(*this);
00992
00993 if(m.FwdElim(c, bWithPartialPivot))
00994 {
00995 if(m.BackElim(c))
00996 return(c);
00997 }
00998 return(smatrix<t>());
00999 }
|
|
||||||||||||||||||||
|
Definition at line 633 of file Smatrix.hpp. 00634 {
00635 const map<size_t, size_t> *Map = (n > p->size() ? (*p)[0] : (*p)[n]);
00636 return(Start <= 1 ? Map->begin() : Map->lower_bound(Start));
00637 }
|
|
||||||||||||||||||||
|
Definition at line 628 of file Smatrix.hpp. Referenced by IterForCol(), IterForRow(), and PivotMap().
00629 {
00630 map<size_t, size_t> *Map = (n > p->size() ? (*p)[0] : (*p)[n]);
00631 return(Start <= 1 ? Map->begin() : Map->lower_bound(Start));
00632 }
|
|
||||||||||||||||
|
Definition at line 658 of file Smatrix.hpp. 00659 { return(IterFor(j, iStart, jMap)); }
|
|
||||||||||||||||
|
Definition at line 656 of file Smatrix.hpp. Referenced by BackElim(), TLUDecomp::BackElim(), TLUDecomp::Decompose(), FwdElim(), TLUDecomp::FwdElim(), PrintListing(), and TLUDecomp::Solve().
00657 { return(IterFor(j, iStart, jMap)); }
|
|
||||||||||||||||
|
Definition at line 650 of file Smatrix.hpp. |
|
||||||||||||||||
|
Definition at line 648 of file Smatrix.hpp. Referenced by PrintListing(), RecalcMaxCoef(), and insert().
|
|
||||||||||||||||||||||||||||
|
Definition at line 762 of file Smatrix.hpp. Referenced by PivotCol(), and PivotRow().
00763 {
00764 iterator p = Dest[k]->lower_bound(k);
00765 if(p == Dest[k]->end())
00766 return(false);
00767 MaxIdx = Index(p);
00768 MaxCoef = Coef(p);
00769 for(p++; p != Dest[k]->end(); p++)
00770 {
00771 if(abs(MaxCoef) < abs(Coef(p)))
00772 {
00773 MaxCoef = Coef(p);
00774 MaxIdx = Index(p);
00775 }
00776 }
00777 if(k != MaxIdx)
00778 PivotMap(k, MaxIdx, Source, Dest);
00779
00780 return(true);
00781 }
|
|
||||||||||||||||||||
|
Definition at line 805 of file Smatrix.hpp. |
|
||||||||||||||||||||
|
Definition at line 799 of file Smatrix.hpp. |
|
||||||||||||||||||||||||
|
Definition at line 718 of file Smatrix.hpp. Referenced by Pivot(), PivotCol(), and PivotRow().
00719 {
00720 bOddNumPivots = (bOddNumPivots == false);
00721 if(a != b)
00722 {
00723 const_iterator ia = IterFor(a, 1, Source);
00724 const_iterator ib = IterFor(b, 1, Source);
00725 while(ia != EndOf(a, Source) || ib != EndOf(b, Source))
00726 {
00727 if(ia == EndOf(a, Source))
00728 {
00729 Dest[Index(ib)]->erase(b);
00730 Dest[Index(ib)]->insert(mapping(a, CoefPtr(ib)));
00731 ib++;
00732 }
00733 else if(ib == EndOf(b, Source))
00734 {
00735 Dest[Index(ia)]->erase(a);
00736 Dest[Index(ia)]->insert(mapping(b, CoefPtr(ia)));
00737 ia++;
00738 }
00739 else if(Index(ia) > Index(ib))
00740 {
00741 Dest[Index(ib)]->erase(b);
00742 Dest[Index(ib)]->insert(mapping(a, CoefPtr(ib)));
00743 ib++;
00744 }
00745 else if(Index(ia) < Index(ib))
00746 {
00747 Dest[Index(ia)]->erase(a);
00748 Dest[Index(ia)]->insert(mapping(b, CoefPtr(ia)));
00749 ia++;
00750 }
00751 else
00752 {
00753 map<size_t, size_t> &p = *Dest[Index(ia)];
00754 swap(p[a], p[b]);
00755 ia++;
00756 ib++;
00757 }
00758 }
00759 }
00760 swap((*Source)[a], (*Source)[b]);
00761 }
|
|
||||||||||||||||||||
|
Definition at line 788 of file Smatrix.hpp. |
|
||||||||||||||||||||
|
Definition at line 782 of file Smatrix.hpp. Referenced by GetDiag().
|
|
||||||||||
|
Definition at line 1019 of file Smatrix.hpp. 01020 {
01021 os << "Matrix" << endl;
01022 os << *this << endl;
01023 os << "vector<t> e" << endl;
01024 for(size_t n = 0; n < e.size(); n++)
01025 os << e[n] << " ";
01026 os << endl << endl;
01027
01028 for(size_t r = 1; r <= iDim; r++)
01029 {
01030 os << "iMap[" << r << "] ";
01031 for(const_iterator i = IterForRow(r); i != EndOfRow(r); i++)
01032 os << "(" << i->first << ", " << i->second << ") ";
01033 os << endl;
01034 }
01035 os << endl;
01036 for(size_t c = 1; c <= jDim; c++)
01037 {
01038 os << "jMap[" << c << "] ";
01039 for(const_iterator j = IterForCol(c); j != EndOfCol(c); j++)
01040 os << "(" << j->first << ", " << j->second << ") ";
01041 os << endl;
01042 }
01043 }
|
|
|||||||||
|
Definition at line 944 of file Smatrix.hpp. Referenced by BackElim().
00945 {
00946 maxCoef = t(0);
00947 epsilon = 0;
00948 for(size_t i = 1; i < iDim; i++)
00949 {
00950 iterator j = IterForRow(i);
00951 for(; j != EndOfRow(i); j++)
00952 CalcEpsilon(maxCoef, epsilon, e[j->second]);
00953 }
00954 }
|
|
|||||||||
|
Definition at line 212 of file Smatrix.hpp. Referenced by reserve().
00213 {
00214 return(FreeSlots + (e.size() - NZ));
00215 }
|
|
||||||||||||||||
|
Definition at line 975 of file Smatrix.hpp. 00976 {
00977 smatrix<t> m, c(*this);
00978 m = L;
00979 if(m.FwdElim(c, false))
00980 {
00981 m = U;
00982 if(m.BackElim(c))
00983 return(c);
00984 }
00985 return(smatrix<t>());
00986 }
|
|
||||||||||
|
Definition at line 875 of file Smatrix.hpp. 00876 {
00877 smatrix<t> m;
00878 if(m.SolveWithGaussElim(*this, bWithPartialPivot) == false)
00879 return(smatrix<t>());
00880 return(m);
00881 }
|
|
||||||||||||||||
|
Definition at line 869 of file Smatrix.hpp. Referenced by SolveWithGaussElim().
|
|
|||||||||
|
Definition at line 216 of file Smatrix.hpp. 00217 {
00218 return((double)NZ / (iDim * jDim));
00219 }
|
|
|||||||||
|
Definition at line 280 of file Smatrix.hpp. |
|
||||||||||||||||
|
Definition at line 273 of file Smatrix.hpp. |
|
||||||||||||||||
|
Definition at line 625 of file Smatrix.hpp. 00626 { return(const_svector_ref(this, range, j)); }
|
|
||||||||||
|
Definition at line 623 of file Smatrix.hpp. 00624 { return(const_svector_ref(this, rng(1, iDim), j)); }
|
|
||||||||||||||||
|
Definition at line 617 of file Smatrix.hpp. 00618 { return(svector_ref(this, range, j)); }
|
|
||||||||||
|
Definition at line 615 of file Smatrix.hpp. Referenced by operator *().
00616 { return(svector_ref(this, rng(1, iDim), j)); }
|
|
||||||||||
|
Definition at line 882 of file Smatrix.hpp. Referenced by det().
|
|
||||||||||||||||
|
Definition at line 582 of file Smatrix.hpp. 00583 {
00584 map<size_t, size_t> *r = (*iMap)[i];
00585 map<size_t, size_t>::iterator p = r->find(j);
00586 if(p != r->end())
00587 {
00588 erase(p->second);
00589 r->erase(p);
00590 (*jMap)[j]->erase(i);
00591 }
00592 }
|
|
||||||||||
|
Definition at line 205 of file Smatrix.hpp. Referenced by BackElim(), FwdElim(), PivotMap(), erase(), smatrix::svector_ref::erase(), and smatrix::coefRef::operator=().
00206 {
00207 e[pos] = FirstBlank;
00208 FirstBlank = pos;
00209 NZ--;
00210 FreeSlots++;
00211 }
|
|
||||||||||||||||||||
|
Definition at line 199 of file Smatrix.hpp. 00200 {
00201 this->iDim = iDim;
00202 this->jDim = jDim;
00203 initialize(MaxNZ);
00204 }
|
|
||||||||||
|
Definition at line 183 of file Smatrix.hpp. Referenced by initialize(), operator *(), operator+(), operator-(), and smatrix().
00184 {
00185 delete(iMap);
00186 iMap = new vector_map;
00187 delete(jMap);
00188 jMap = new vector_map;
00189 e.reserve(MaxNZ);
00190 iMap->resize(iDim + 1);
00191 jMap->resize(jDim + 1);
00192 FirstBlank = (size_t)-1;
00193 NZ = 0;
00194 FreeSlots = 0;
00195 bOddNumPivots = false;
00196 epsilon = 0;
00197 maxCoef = 0;
00198 }
|
|
||||||||||||||||||||
|
Definition at line 266 of file Smatrix.hpp. 00267 {
00268 iterator iIter, jIter;
00269 if(insert(i, j, d, iIter, jIter))
00270 return(iIter);
00271 return(IterForRow(0, 0));
00272 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 226 of file Smatrix.hpp. Referenced by PivotMap(), ZeroInsert(), smatrix::svector_ref::insert(), insert(), operator *(), smatrix::coefRef::operator=(), smIdentity::smIdentity(), and smatrix().
00227 {
00228 if(bZeroInsert == false && abs(d) <= epsilon)
00229 return(false);
00230
00231 size_t pos;
00232 if(FirstBlank != (size_t)-1)
00233 {
00234 pos = FirstBlank;
00235 FirstBlank = (size_t)e[pos];
00236 FreeSlots--;
00237 }
00238 else
00239 {
00240 if(e.capacity() == e.size())
00241 e.reserve(e.size() + (e.size() / 10));
00242 pos = e.size();
00243 e.insert(e.end());
00244 }
00245 NZ++;
00246
00247 e[pos] = d;
00248 CalcEpsilon(maxCoef, epsilon, d);
00249
00250 if(i > iDim)
00251 {
00252 iDim = i;
00253 iMap->resize(iDim + 1);
00254 }
00255 jIter = (*iMap)[i]->insert(mapping(j, pos)).first;
00256
00257 if(j > jDim)
00258 {
00259 jDim = j;
00260 jMap->resize(jDim + 1);
00261 }
00262 iIter = (*jMap)[j]->insert(mapping(i, pos)).first;
00263
00264 return(true);
00265 }
|
|
||||||||||||||||
|
Definition at line 918 of file Smatrix.hpp. 00919 {
00920 smatrix<t> m;
00921 return(m.lnScaledDet(*this, lnScale, bWithPartialPivot));
00922 }
|
|
||||||||||||||||||||
|
Definition at line 913 of file Smatrix.hpp. 00914 {
00915 *this = m;
00916 return(lnScaledDet(lnScale, bWithPartialPivot));
00917 }
|
|
||||||||||||||||
|
Definition at line 891 of file Smatrix.hpp. Referenced by lnScaledDet().
00892 {
00893 lnScale = t(0);
00894
00895 if(iDim != jDim) return(t(0));
00896 FwdElim(bWithPartialPivot, true);
00897 int sign = (bOddNumPivots ? -1 : 1);
00898
00899 for(size_t k = 1; k <= iDim; k++)
00900 {
00901 t d;
00902 if(!GetDiag(k, d, false)) return(false);
00903 if(d > 0)
00904 lnScale += log(d);
00905 else
00906 {
00907 sign *= -1;
00908 lnScale += log(-d);
00909 }
00910 }
00911 return(sign);
00912 }
|
|
||||||||||
|
Definition at line 1014 of file Smatrix.hpp. 01015 {
01016 smatrix<t> c(*this);
01017 return(c *= d);
01018 }
|
|
||||||||||
|
Definition at line 681 of file Smatrix.hpp. 00682 {
00683 smatrix<t> c;
00684
00685 c.iDim = iDim;
00686 c.jDim = b.jDim;
00687 size_t MaxNZ = max(NZ, b.NZ);
00688 if(c.iDim == 1 && c.jDim == 1) MaxNZ = 1;
00689 else if(c.iDim == 1 || c.jDim == 1) MaxNZ = max(c.iDim, c.jDim);
00690 c.initialize(MaxNZ);
00691
00692 for(size_t i = 1; i <= iDim; i++)
00693 {
00694 const_svector_ref r = row(i);
00695 for(size_t j = 1; j <= b.jDim; j++)
00696 {
00697 t d = svMultiply(r, b.col(j));
00698 c.insert(i, j, d);
00699 }
00700 }
00701 return(c);
00702 }
|
|
||||||||||
|
Definition at line 1008 of file Smatrix.hpp. |
|
|||||||||
|
Definition at line 717 of file Smatrix.hpp. 00717 { return(NZ == 0); }
|
|
||||||||||
|
Definition at line 713 of file Smatrix.hpp. 00714 {
00715 return(operator==(b) == false);
00716 }
|
|
||||||||||||||||
|
Definition at line 608 of file Smatrix.hpp. 00609 { return(const_svector_ref(this, range, j)); }
|
|
||||||||||||||||
|
Definition at line 606 of file Smatrix.hpp. |
|
||||||||||||||||
|
Definition at line 604 of file Smatrix.hpp. 00605 { return(svector_ref(this, range, j)); }
|
|
||||||||||||||||
|
Definition at line 602 of file Smatrix.hpp. |
|
||||||||||||||||
|
Definition at line 578 of file Smatrix.hpp. 00579 {
00580 return(coefRef(this, i, j));
00581 }
|
|
||||||||||||||||
|
Definition at line 524 of file Smatrix.hpp. 00525 {
00526 if(i > iDim || j > jDim) return(0);
00527 const map<size_t, size_t> *r = (*iMap)[i];
00528 map<size_t, size_t>::const_iterator p = r->find(j);
00529 if(p == r->end())
00530 return(0);
00531 return(e[p->second]);
00532 }
|
|
||||||||||
|
Definition at line 665 of file Smatrix.hpp. |
|
||||||||||
|
Definition at line 673 of file Smatrix.hpp. |
|
||||||||||
|
Definition at line 161 of file Smatrix.hpp. 00162 {
00163 e = a.e;
00164 epsilon = a.epsilon;
00165 maxCoef = a.maxCoef;
00166
00167 delete(iMap);
00168 iMap = new vector_map;
00169 *iMap = *a.iMap;
00170
00171 delete(jMap);
00172 jMap = new vector_map;
00173 *jMap = *a.jMap;
00174
00175 NZ = a.NZ;
00176 iDim = a.iDim;
00177 jDim = a.jDim;
00178 FirstBlank = a.FirstBlank;
00179 bOddNumPivots = a.bOddNumPivots;
00180
00181 return(*this);
00182 }
|
|
||||||||||
|
Definition at line 703 of file Smatrix.hpp. Referenced by operator!=().
|
|
||||||||||
|
Definition at line 220 of file Smatrix.hpp. 00221 {
00222 size_t slack = SlackSpace();
00223 if(slack < space)
00224 e.reserve(space - FreeSlots);
00225 }
|
|
||||||||||||||||
|
Definition at line 621 of file Smatrix.hpp. |
|
||||||||||
|
Definition at line 619 of file Smatrix.hpp. |
|
||||||||||||||||
|
Definition at line 613 of file Smatrix.hpp. |
|
||||||||||
|
Definition at line 611 of file Smatrix.hpp. Referenced by BackElim(), TLUDecomp::BackElim(), TLUDecomp::Decompose(), FwdElim(), TLUDecomp::FwdElim(), TLUDecomp::L(), TLUDecomp::Solve(), TLUDecomp::U(), operator *(), operator+(), operator-(), and operator==().
|
|
||||||||||||||||||||
|
Definition at line 286 of file Smatrix.hpp. Referenced by operator *(), smatrix::const_svector_ref::operator *(), and smatrix::svector::operator *().
00287 {
00288 size_t first = max(a.range.first, b.range.first);
00289 size_t last = min(a.range.second, b.range.second);
00290
00291 ta::const_iterator ia = a.lower_bound(first);
00292 ta::const_iterator iaEnd = a.lower_bound(last + 1);
00293
00294 tb::const_iterator ib = b.lower_bound(first);
00295 tb::const_iterator ibEnd = b.lower_bound(last + 1);
00296
00297 t d(0);
00298 while(ia != iaEnd && ib != ibEnd)
00299 {
00300 if(a.Index(ia) < b.Index(ib))
00301 ia++;
00302 else if(a.Index(ia) > b.Index(ib))
00303 ib++;
00304 else
00305 {
00306 addEq(d, a.Coef(ia) * b.Coef(ib), false);
00307 ia++;
00308 ib++;
00309 }
00310 }
00311 return(d);
00312 }
|
|
|||||
|
Definition at line 126 of file Smatrix.hpp. Referenced by operator=().
|
|
|||||
|
Definition at line 126 of file Smatrix.hpp. |
|
|||||
|
Definition at line 126 of file Smatrix.hpp. Referenced by TLUDecomp::Solve(), operator *(), operator+(), operator-(), operator<<(), operator=(), and operator==().
|
|
|||||
|
Definition at line 6 of file test_sm.cpp. |
|
|||||
|
Definition at line 5 of file test_sm.cpp. |
|
|||||
|
Definition at line 127 of file Smatrix.hpp. Referenced by operator=().
|
|
|||||
|
Definition at line 123 of file Smatrix.hpp. Referenced by smatrix::svector_ref::Coef(), smatrix::const_svector_ref::Coef(), smatrix::coefRef::operator t(), smatrix::svector_ref::operator()(), smatrix::const_svector_ref::operator()(), smatrix::coefRef::operator=(), and operator=().
|
|
|||||
|
Definition at line 124 of file Smatrix.hpp. Referenced by smatrix::svector_ref::CalcEpsilon(), smatrix::const_svector_ref::GetEpsilon(), Inverse(), operator<<(), smatrix::coefRef::operator=(), and operator=().
|
|
|||||
|
Definition at line 126 of file Smatrix.hpp. Referenced by TLUDecomp::Solve(), operator *(), smatrix::coefRef::operator t(), operator+(), operator-(), operator<<(), smatrix::coefRef::operator=(), operator=(), and operator==().
|
|
|||||
|
Definition at line 125 of file Smatrix.hpp. Referenced by smatrix::svector_ref::GetMap(), smatrix::const_svector_ref::GetMap(), smatrix::svector_ref::erase(), smatrix::coefRef::operator t(), smatrix::coefRef::operator=(), and operator=().
|
|
|||||
|
Definition at line 126 of file Smatrix.hpp. Referenced by TLUDecomp::Solve(), operator *(), smatrix::coefRef::operator t(), operator+(), operator-(), operator<<(), smatrix::coefRef::operator=(), operator=(), and operator==().
|
|
|||||
|
Definition at line 125 of file Smatrix.hpp. Referenced by smatrix::svector_ref::GetMap(), smatrix::const_svector_ref::GetMap(), smatrix::svector_ref::erase(), and operator=().
|
|
|||||
|
Definition at line 124 of file Smatrix.hpp. Referenced by smatrix::svector_ref::CalcEpsilon(), operator<<(), smatrix::coefRef::operator=(), and operator=().
|
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001