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

C:/temp/src/j2k/Beta/Math/Vector/NotDone/Gauss/Smatrix.hpp File Reference

#include <map>
#include <vector>
#include <float.h>
#include <math.h>

Go to the source code of this file.

Compounds

class  smatrix::coefRef
class  smatrix::const_svector_ref
class  smatrix
class  smatrix::vector_map
class  smatrix::svector
class  smatrix::svector_ref
class  smIdentity

Typedefs

typedef pair< size_t, size_t > rng

Functions

template<class t> void addEq (t &a, const t &b, bool bNeg)
template<class t> void CalcEpsilon (t &maxCoef, t &epsilon, const t &d)
template<class t> t abs (const t &x)
template<class t> t max (const t &a, const t &b)
template<class t> t min (const t &a, const t &b)
template<class ta, class tb> ta & svAssign (ta &a, const tb &b)
template<class ta, class tb> ta & svAddEq (ta &a, const tb &b, bool bNegate)
template<class t> smatrix< t > operator * (const t &d, const smatrix< t > &m)
template<class t> t det (const smatrix< t > &m, bool bWithPartialPivot=true)
template<class t> ostream & operator<< (ostream &os, const smatrix< t >::svector &v)
template<class t> ostream & operator<< (ostream &os, const smatrix< t >::const_svector_ref &v)
template<class t> ostream & operator<< (ostream &os, const smatrix< t > &m)
template<class t> t Residual (const smatrix< t > &a, const smatrix< t > &b)
void CalcEpsilon (double &maxCoef, double &epsilon, const double &d)


Typedef Documentation

typedef pair<size_t, size_t> rng
 

Definition at line 14 of file Smatrix.hpp.

Referenced by smatrix::BackElim(), TLUDecomp::Decompose(), smatrix::FwdElim(), TLUDecomp::L(), TLUDecomp::U(), smatrix::col(), operator<<(), and smatrix::row().


Function Documentation

void CalcEpsilon double &    maxCoef,
double &    epsilon,
const double &    d
[inline]
 

Definition at line 1114 of file Smatrix.hpp.

Referenced by smatrix::svector_ref::CalcEpsilon(), smatrix::svector::CalcEpsilon(), smatrix::RecalcMaxCoef(), smatrix::insert(), and smatrix::coefRef::operator=().

01115 {
01116     double ep = abs(d);
01117     if(maxCoef < ep) {
01118         maxCoef = ep;
01119         epsilon = max(ep * DBL_EPSILON, epsilon); }
01120 }

template<class t>
void CalcEpsilon t &    maxCoef,
t &    epsilon,
const t &    d
[inline]
 

template<class t>
t Residual const smatrix< t > &    a,
const smatrix< t > &    b
[inline]
 

Definition at line 1109 of file Smatrix.hpp.

01110 {
01111     return((a - b).maxCoef);
01112 }

template<class t>
t abs const t &    x [inline]
 

Definition at line 10 of file Smatrix.hpp.

Referenced by Vector4D::Abs(), JVector3D::Abs(), TLUDecomp::Decompose(), smatrix::FwdElim(), smatrix::GetDiag(), smatrix::Pivot(), JVector2D::ToRadians(), Vector4D::ToRadians(), JVector3D::ToRadians(), smatrix::insert(), and smatrix::coefRef::operator=().

00010 { return(x < 0 ? -x : x); }

template<class t>
void addEq t &    a,
const t &    b,
bool    bNeg
[inline]
 

Definition at line 6 of file Smatrix.hpp.

Referenced by svAddEq(), and smatrix::svMultiply().

00007 { if(bNeg) a -= b; else a += b; }

template<class t>
t det const smatrix< t > &    m,
bool    bWithPartialPivot = true
[inline]
 

Definition at line 1061 of file Smatrix.hpp.

01062 {
01063     smatrix<t> c(m);
01064     return(c.det(bWithPartialPivot));
01065 }

template<class t>
t max const t &    a,
const t &    b
[inline]
 

Definition at line 11 of file Smatrix.hpp.

00011 { return(a > b ? a : b); }

template<class t>
t min const t &    a,
const t &    b
[inline]
 

Definition at line 12 of file Smatrix.hpp.

00012 { return(a < b ? a : b); }

template<class t>
smatrix<t> operator * const t &    d,
const smatrix< t > &    m
 

Definition at line 1046 of file Smatrix.hpp.

01047 {
01048     return(m * d);
01049 }

template<class t>
ostream& operator<< ostream &    os,
const smatrix< t > &    m
[inline]
 

Definition at line 1089 of file Smatrix.hpp.

01090 {
01091     if(m.NZ > 0)
01092     {
01093         if(m.iDim < 20)
01094         {
01095             for(size_t i = 1; i <= m.iDim; i++)
01096                 os << m(i, rng(1, m.jDim)) << endl;
01097         }
01098         else
01099         {
01100             os << m.iDim << " x " << m.jDim << ", NZ = " << m.NZ << endl;
01101             os << "Max coef = " << m.maxCoef << ", epsilon = " << m.epsilon << endl;
01102         }
01103     }
01104     else
01105         os << "<null>";
01106     return(os);
01107 }

template<class t>
ostream& operator<< ostream &    os,
const smatrix< t >::const_svector_ref &    v
[inline]
 

Definition at line 1078 of file Smatrix.hpp.

01079 {
01080     for(size_t n = v.range.first; n <= v.range.second; n++)
01081     {
01082         os.width(smatrix<t>::PrintWidth);
01083         os.precision(smatrix<t>::PrintPrecision);
01084         os << v(n);
01085     }
01086     return(os);
01087 }

template<class t>
ostream& operator<< ostream &    os,
const smatrix< t >::svector &    v
[inline]
 

Definition at line 1067 of file Smatrix.hpp.

01068 {
01069     for(size_t n = v.range.first; n <= v.range.second; n++)
01070     {
01071         os.width(smatrix<t>::PrintWidth);
01072         os.precision(smatrix<t>::PrintPrecision);
01073         os << v(n);
01074     }
01075     return(os);
01076 }

template<class ta, class tb>
ta& svAddEq ta &    a,
const tb &    b,
bool    bNegate
 

Definition at line 51 of file Smatrix.hpp.

Referenced by smatrix::const_svector_ref::operator+(), smatrix::svector_ref::operator+=(), smatrix::const_svector_ref::operator-(), and smatrix::svector_ref::operator-=().

00052 {
00053     ta::iterator ia = a.lower_bound(min(b.range.first, a.range.second + 1));
00054     ta::iterator iaEnd = a.lower_bound(a.range.second + 1);
00055     tb::const_iterator ib = b.lower_bound(b.range.first);
00056     tb::const_iterator ibEnd = b.lower_bound(b.range.second + 1);
00057 
00058     while(ib != ibEnd)
00059     {
00060         if(ia == iaEnd)
00061         {
00062             ta::iterator iaNew = a.insert(ia, b.Index(ib), bNegate ? -b.Coef(ib) : b.Coef(ib));
00063             if(iaNew != ia)
00064                 iaEnd = ia = ++iaNew;
00065             ib++;
00066         }
00067         else if(a.Index(ia) > b.Index(ib))
00068         {
00069             ta::iterator iaNew = a.insert(ia, b.Index(ib), bNegate ? -b.Coef(ib) : b.Coef(ib));
00070             if(iaNew != ia)
00071                 ia = ++iaNew;
00072             ib++;
00073         }
00074         else if(a.Index(ia) < b.Index(ib))
00075             ia++;
00076         else
00077         {
00078             addEq(a.Coef(ia), b.Coef(ib++), bNegate);
00079             a.CalcEpsilon(a.Coef(ia));
00080             ia++;
00081         }
00082     }
00083 
00084     a.range.first = min(a.range.first, b.range.first);
00085     a.range.second = max(a.range.second, b.range.second);
00086 
00087     return(a);
00088 }

template<class ta, class tb>
ta& svAssign ta &    a,
const tb &    b
 

Definition at line 18 of file Smatrix.hpp.

Referenced by smatrix::const_svector_ref::operator+(), smatrix::const_svector_ref::operator-(), and smatrix::svector_ref::operator=().

00019 {
00020     a.range = b.range;
00021     ta::iterator ia = a.lower_bound(0);
00022     ta::iterator iaEnd = a.lower_bound((size_t)-1);
00023     tb::const_iterator ib = b.lower_bound(b.range.first);
00024     tb::const_iterator ibEnd = b.lower_bound(b.range.second + 1);
00025     while(ia != iaEnd || ib != ibEnd)
00026     {
00027         if(ia == iaEnd)
00028         {
00029             ta::iterator iaNew = a.insert(ia, b.Index(ib), b.Coef(ib));
00030             if(iaNew != ia)
00031                 iaEnd = ia = ++iaNew;
00032             ib++;
00033         }
00034         else if(ib == ibEnd)
00035             ia = a.erase(ia);
00036         else if(a.Index(ia) < b.Index(ib))
00037             ia = a.erase(ia);
00038         else if(a.Index(ia) > b.Index(ib))
00039         {
00040             ta::iterator iaNew = a.insert(ia, b.Index(ib), b.Coef(ib));
00041             if(iaNew != ia)
00042                 ia = ++iaNew;
00043             ib++;
00044         }
00045         else
00046             a.Coef(ia++) = b.Coef(ib++);
00047     }
00048     return(a);
00049 }


Generated on Sun Oct 14 18:47:00 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001