STK::MatrixLowerTriangular Class Reference
[Subproject STKAlgebra::TempExp]

Declaration of the lower triangular matrix class. More...

#include <STK_MatrixLowerTriangular.h>

Inherits IArray2D< Real, MatrixLowerTriangular >.

List of all members.

Public Types

typedef Array1D< Real_Cont1DType
typedef ArrayHo< Real_ContHoType
typedef IArray2D< Real,
MatrixLowerTriangular
_IArray2DType

Public Member Functions

 MatrixLowerTriangular (const Inx &I=Inx(), const Inx &J=Inx())
 MatrixLowerTriangular (const Inx &I, const Inx &J, const Real &v)
 MatrixLowerTriangular (const MatrixLowerTriangular &T, bool ref=false)
 MatrixLowerTriangular (const _IArray2DType &T, const Inx &I, const Inx &J)
 MatrixLowerTriangular (Real **q, const Inx &I, const Inx &J)
virtual ~MatrixLowerTriangular ()
Integer compFirstVe (const Integer &icol) const
Integer compLastVe (const Integer &icol) const
Integer compSizeVe (const Integer &icol) const
Inx compRangeVe (const Integer &icol) const
Integer compFirstHo (const Integer &irow) const
Integer compLastHo (const Integer &irow) const
Integer compSizeHo (const Integer &irow) const
Inx compRangeHo (const Integer &irow) const
bool isInside (const Integer &i, const Integer &j) const
RealgetElt (Integer i, Integer j)
const RealgetElt (Integer i, Integer j) const
MatrixLowerTriangular get2D (const Inx &I, const Inx &J) const
_Cont1DType getCol (const Inx &I, Integer j) const
_ContHoType getRow (Integer i, const Inx &J) const
MatrixLowerTriangularoperator= (const MatrixLowerTriangular &T)
MatrixLowerTriangularoperator= (const Real &v)

Private Attributes

const Real defaultConst_
Real default_


Detailed Description

A MatrixLowerTriangular is a column oriented 2D lower triangular container of Real. It is possible to add/remove rows and columns but in this case the container will no more be triangular. The container can be set lower triangular again using the method IArray2D::update().

Definition at line 66 of file STK_MatrixLowerTriangular.h.


Member Typedef Documentation

Column Real.

Definition at line 79 of file STK_MatrixLowerTriangular.h.

Row Real.

Definition at line 82 of file STK_MatrixLowerTriangular.h.

Real for the Interface Class.

Definition at line 85 of file STK_MatrixLowerTriangular.h.


Constructor & Destructor Documentation

STK::MatrixLowerTriangular::MatrixLowerTriangular ( const Inx I = Inx(),
const Inx J = Inx() 
)

Default Ctor. Default is I=(1:0) and J=(1:0)

Parameters:
I range of the Rows
J range of the Cols

Definition at line 55 of file STK_MatrixLowerTriangular.cpp.

References STK::IArray2D< Real, MatrixLowerTriangular >::initializeCols().

Referenced by get2D().

00056                                             : _IArray2DType(I, J)
00057                                             , defaultConst_(Real())
00058 {
00059   // initialize vertically the container
00060   this->initializeCols(J);
00061 }

STK::MatrixLowerTriangular::MatrixLowerTriangular ( const Inx I,
const Inx J,
const Real v 
)

Ctor with rangeVe_ and rageHo_ specified, initialization with a specified value.

Parameters:
I range of the Rows
J range of the Cols
v initial value in the container

Definition at line 69 of file STK_MatrixLowerTriangular.cpp.

References STK::Inx::first(), STK::IArrayBase< Real * >::getData(), STK::IArray2D< Real, MatrixLowerTriangular >::initializeCols(), STK::Inx::last(), and STK::IArray2DBase< Real, Real *, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >::rangeCols_.

00073                                             : _IArray2DType(I, J)
00074                                             , defaultConst_(Real())
00075 {
00076   // initialize vertically the container
00077   this->initializeCols(J);
00078   // initialize with v
00079   for (Integer j = J.first(); j <= J.last(); j++)
00080   {
00081     Real* p(this->getData(j));
00082     Integer beg(this->rangeCols_[j].first());
00083     Integer end(this->rangeCols_[j].last());
00084 
00085     for (Integer i = beg; i <= end; i++) p[i] = v;
00086   }
00087 }

STK::MatrixLowerTriangular::MatrixLowerTriangular ( const MatrixLowerTriangular T,
bool  ref = false 
)

Copy Ctor.

Parameters:
T the container to copy
ref true if T is wrapped

Definition at line 93 of file STK_MatrixLowerTriangular.cpp.

References STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::firstCol(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::firstRow(), STK::IArrayBase< DATA >::getData(), STK::IArrayBase< Real * >::getData(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::getRangeHo(), STK::IArray2D< Real, MatrixLowerTriangular >::initializeCols(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::lastCol(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::lastRow(), and pt().

00096                                             : _IArray2DType(T, ref)
00097                                             , defaultConst_(Real())
00098 {
00099   if (!ref)
00100   {
00101     // initialize vertically the container
00102     this->initializeCols(T.getRangeHo());
00103     // initialize with T
00104     for (Integer j=T.firstCol(); j<=T.lastCol(); j++)
00105     {
00106       Real* p(this->getData(j));
00107       const Real* pt= T.getData(j);
00108 
00109       for (Integer i=T.firstRow(); i<=T.lastRow(); i++) p[i]= pt[i];
00110     }
00111   }
00112 }

STK::MatrixLowerTriangular::MatrixLowerTriangular ( const _IArray2DType T,
const Inx I,
const Inx J 
)

Ctor by reference, ref_=1.

Parameters:
T the container to wrap
I range of the Rows to wrap
J range of the Cols to wrap

Definition at line 119 of file STK_MatrixLowerTriangular.cpp.

00123                                             : _IArray2DType(T, I, J)
00124                                             , defaultConst_(Real())
00125 { ;}

STK::MatrixLowerTriangular::MatrixLowerTriangular ( Real **  q,
const Inx I,
const Inx J 
)

Wrapper Ctor. Contruct a reference container.

Parameters:
q pointer on the data
I range of the Rows to wrap
J range of the Cols to wrap

Definition at line 132 of file STK_MatrixLowerTriangular.cpp.

00136                                             : _IArray2DType(q, I, J)
00137                                             , defaultConst_(Real())
00138 { ;}

STK::MatrixLowerTriangular::~MatrixLowerTriangular (  )  [virtual]

virtual Dtor : use Dtor of Array2D.

Definition at line 142 of file STK_MatrixLowerTriangular.cpp.

00143 { ;}


Member Function Documentation

Integer STK::MatrixLowerTriangular::compFirstVe ( const Integer icol  )  const [inline]

Compute the first index of the column icol.

Parameters:
icol the index of the column we want to compute the first index

Definition at line 133 of file STK_MatrixLowerTriangular.h.

References STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >::firstCol(), STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >::firstRow(), and STK::max().

Referenced by compRangeVe(), compSizeVe(), and isInside().

00134     {
00135       return max( this->firstRow()+ icol - this->firstCol(), this->firstRow());
00136     }

Integer STK::MatrixLowerTriangular::compLastVe ( const Integer icol  )  const [inline]

Compute the last index of the column icol. For a lower triangular matrix, this is the index of the last row.

Parameters:
icol the column we want to know the last index

Definition at line 142 of file STK_MatrixLowerTriangular.h.

References STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >::lastRow().

00143     {
00144       return this->lastRow();
00145     }

Integer STK::MatrixLowerTriangular::compSizeVe ( const Integer icol  )  const [inline]

Compute the size of the column icol.

Parameters:
icol the column we want to know the size

Definition at line 150 of file STK_MatrixLowerTriangular.h.

References compFirstVe(), STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >::lastRow(), and STK::max().

00151     {
00152       return max(this->lastRow()-compFirstVe(icol)+1, Integer(0));
00153     }

Inx STK::MatrixLowerTriangular::compRangeVe ( const Integer icol  )  const [inline]

compute the range of the effectively stored elements in the col icol.

Parameters:
icol the number of the column to compute the range

Definition at line 159 of file STK_MatrixLowerTriangular.h.

References compFirstVe(), and STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >::lastRow().

Referenced by getCol().

00160     {
00161       return Inx(compFirstVe(icol), this->lastRow());
00162     }

Integer STK::MatrixLowerTriangular::compFirstHo ( const Integer irow  )  const [inline]

compute the beginning of the row irow.

Parameters:
irow the column to compute the beginning

Definition at line 167 of file STK_MatrixLowerTriangular.h.

References STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >::firstCol().

00168     {
00169       return this->firstCol();
00170     }

Integer STK::MatrixLowerTriangular::compLastHo ( const Integer irow  )  const [inline]

Integer STK::MatrixLowerTriangular::compSizeHo ( const Integer irow  )  const [inline]

compute the true number of element of the row irow.

Parameters:
irow the number of the column to compute the size

Definition at line 184 of file STK_MatrixLowerTriangular.h.

References compLastHo(), STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >::firstCol(), and STK::max().

00185     {
00186       return max(compLastHo(irow)-this->firstCol()+1, Integer(0));
00187     }

Inx STK::MatrixLowerTriangular::compRangeHo ( const Integer irow  )  const [inline]

compute the range of the effectively stored elements in the row irow.

Parameters:
irow the number of the row to compute the range

Definition at line 193 of file STK_MatrixLowerTriangular.h.

References compLastHo(), and STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >::firstCol().

Referenced by getRow().

00194     {
00195       return Inx(this->firstCol(), this->compLastHo(irow));
00196     }

bool STK::MatrixLowerTriangular::isInside ( const Integer i,
const Integer j 
) const [inline]

function for determining if the row i of the col j is in the lower triangular part.

Parameters:
i the number of the row
j the number of the col

Definition at line 203 of file STK_MatrixLowerTriangular.h.

References compFirstVe().

Referenced by getElt().

00204     {
00205       return (i>=compFirstVe(j));
00206     }

Real& STK::MatrixLowerTriangular::getElt ( Integer  i,
Integer  j 
) [inline]

access to one element.

Parameters:
i index of the row
j index of the col

Definition at line 214 of file STK_MatrixLowerTriangular.h.

References default_, STK::IArrayBase< Real * >::getData(), and isInside().

00215     {
00216       return isInside(i, j) ? this->getData(j)[i] : default_;
00217     }

const Real& STK::MatrixLowerTriangular::getElt ( Integer  i,
Integer  j 
) const [inline]

access to one element const.

Parameters:
i index of the row
j index of the col

Definition at line 223 of file STK_MatrixLowerTriangular.h.

References defaultConst_, STK::IArrayBase< Real * >::getData(), and isInside().

00224     {
00225       if (isInside(i, j))
00226       {
00227         return this->getData(j)[i];
00228       }
00229       else
00230       {
00231         return defaultConst_;
00232       }
00233     }

MatrixLowerTriangular STK::MatrixLowerTriangular::get2D ( const Inx I,
const Inx J 
) const [inline]

access to a sub-array.

Parameters:
I range of the rows
J range of the cols

Definition at line 239 of file STK_MatrixLowerTriangular.h.

References MatrixLowerTriangular().

00240     {
00241       return MatrixLowerTriangular(*this, I, J);
00242     }

_Cont1DType STK::MatrixLowerTriangular::getCol ( const Inx I,
Integer  j 
) const [inline]

access to a sub-col.

Parameters:
I range of the rows
j index of the col

Definition at line 248 of file STK_MatrixLowerTriangular.h.

References compRangeVe(), STK::IArrayBase< Real * >::getData(), and STK::Inx::inf().

00249     {
00250       return _Cont1DType( this->getData(j)
00251                         , Inx::inf(I, compRangeVe(j))
00252                         , j);
00253     }

_ContHoType STK::MatrixLowerTriangular::getRow ( Integer  i,
const Inx J 
) const [inline]

access to a sub-row.

Parameters:
i index of the row
J range of the cols

Definition at line 259 of file STK_MatrixLowerTriangular.h.

References compRangeHo(), and STK::Inx::inf().

00260     {
00261       return _ContHoType(*this, Inx::inf(J, compRangeHo(i)), i);
00262     }

MatrixLowerTriangular & STK::MatrixLowerTriangular::operator= ( const MatrixLowerTriangular T  ) 

operator = : overwrite the MatrixLowerTriangular with T. We resize the object if this and T does not have the same size but if they have the same size, we don't modify the range of the object.

Parameters:
T the container to copy

Definition at line 152 of file STK_MatrixLowerTriangular.cpp.

References STK::ITContainer1D< TYPE, TContainer1D >::first(), STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >::firstCol(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::firstCol(), STK::IArrayBase< DATA >::getData(), STK::IArrayBase< Real * >::getData(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::getRangeHo(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::getRangeVe(), STK::IArray2D< Real, MatrixLowerTriangular >::initialize(), STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >::lastCol(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::lastCol(), pt(), STK::IArray2DBase< TYPE, PTRCOL, TArrayHo, TArrayVe, TArray2D >::rangeCols_, STK::IArray2DBase< Real, Real *, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >::rangeCols_, STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::sizeHo(), STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >::sizeHo(), STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::sizeVe(), and STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >::sizeVe().

00153 {
00154   // Resize if necessary.
00155   if ( (this->sizeVe() != T.sizeVe())||(this->sizeHo() != T.sizeHo()))
00156   {
00157     this->initialize(T.getRangeVe(), T.getRangeHo());
00158   }
00159   // coopy without overlapping
00160   if (T.firstCol()>=this->firstCol())
00161   {
00162     for ( Integer jt=T.firstCol(), j=this->firstCol()
00163         ; jt<=T.lastCol()
00164         ; j++, jt++)
00165     {
00166       Real* p(this->getData(j));
00167       const Real* pt= T.getData(jt);
00168       Integer beg(this->rangeCols_[j].first());
00169       Integer end(this->rangeCols_[j].last());
00170       Integer tbeg(T.rangeCols_[j].first());
00171 
00172       for (Integer i=beg, it=tbeg; i<=end; i++, it++)
00173         p[i]= pt[it];
00174     }
00175     return *this;
00176   }
00177   // T.firstCol()<this->firstCol()
00178   for ( Integer jt=T.lastCol(), j=this->lastCol()
00179       ; jt>=T.firstCol()
00180       ; j--, jt--)
00181   {
00182     Real* p(this->getData(j));
00183     const Real* pt= T.getData(jt);
00184     Integer beg(this->rangeCols_[j].first());
00185     Integer end(this->rangeCols_[j].last());
00186     Integer tbeg(T.rangeCols_[j].first());
00187 
00188     for (Integer i=beg, it=tbeg; i<=end; i++, it++)
00189       p[i]= pt[it];
00190   }
00191   return *this;
00192 }

MatrixLowerTriangular& STK::MatrixLowerTriangular::operator= ( const Real v  )  [inline]

operator= : set the container to a constant value.

Parameters:
v the value to set

Definition at line 276 of file STK_MatrixLowerTriangular.h.

References STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >::firstCol(), STK::IArrayBase< Real * >::getData(), STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >::lastCol(), and STK::IArray2DBase< Real, Real *, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >::rangeCols_.

00277     {
00278       for (Integer j=this->firstCol(); j<=this->lastCol(); j++)
00279       {
00280         Real* p(this->getData(j));
00281         Integer beg(this->rangeCols_[j].first());
00282         Integer end(this->rangeCols_[j].last());
00283 
00284         for (Integer i=beg; i<=end; i++) p[i]= v;
00285       }
00286       return *this;
00287     }


Member Data Documentation

Default constant value (Real(0)).

Definition at line 70 of file STK_MatrixLowerTriangular.h.

Referenced by getElt().

Default non constant value.

Definition at line 73 of file STK_MatrixLowerTriangular.h.

Referenced by getElt().


The documentation for this class was generated from the following files:

Generated on Fri Sep 25 10:31:00 2009 for STK++ by  doxygen 1.5.8