STK++ 1.0

STK::MatrixLowerTriangular Class Reference

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

#include <STK_MatrixLowerTriangular.h>

Inheritance diagram for STK::MatrixLowerTriangular:

List of all members.

Public Types

typedef IArray2D< Real,
MatrixLowerTriangular
_IArray2DType
 Real for the Interface Class.

Public Member Functions

 MatrixLowerTriangular (Range const &I=Range(), Range const &J=Range())
 Default constructor Default is I=(1:0) and J=(1:0)
 MatrixLowerTriangular (Range const &I, Range const &J, Real const &v)
 constructor with rangeVe_ and rageHo_ specified, initialization with a specified value.
 MatrixLowerTriangular (const MatrixLowerTriangular &T, bool ref=false)
 Copy constructor.
 MatrixLowerTriangular (const _IArray2DType &T, Range const &I, Range const &J)
 constructor by reference, ref_=1.
 MatrixLowerTriangular (Real **q, Range const &I, Range const &J)
 Wrapper constructor Contruct a reference container.
virtual ~MatrixLowerTriangular ()
 virtual destructor : use destructor of Array2D.
Integer compFirstVe (Integer const &icol) const
 Compute the first index of the column icol.
Integer compLastVe (Integer const &icol) const
 Compute the last index of the column icol.
Integer compSizeVe (Integer const &icol) const
 Compute the size of the column icol.
Range compRangeVe (Integer const &icol) const
 compute the range of the effectively stored elements in the col icol.
Integer compFirstHo (Integer const &irow) const
 compute the beginning of the row irow.
Integer compLastHo (Integer const &irow) const
 compute the end of the row irow.
Integer compSizeHo (Integer const &irow) const
 compute the true number of element of the row irow.
Range compRangeHo (Integer const &irow) const
 compute the range of the effectively stored elements in the row irow.
bool isInside (Integer const &i, Integer const &j) const
 function for determining if the row i of the col j is in the lower triangular part.
Realelt (Integer i, Integer j)
 access to one element.
Real const & elt (Integer i, Integer j) const
 access to one element const.
MatrixLowerTriangular get2D (Range const &I, Range const &J) const
 access to a sub-array.
Vector col (Range const &I, Integer j) const
 access to a part of a column.
Vector col (Integer j) const
 access to a part of a column.
Point row (Integer i, Range const &J) const
 access to a part of a row.
Point row (Integer i) const
 access to a part of a row.
MatrixLowerTriangularoperator= (const MatrixLowerTriangular &T)
 operator = : overwrite the MatrixLowerTriangular with T.
MatrixLowerTriangularoperator= (Real const &v)
 operator= : set the container to a constant value.

Private Attributes

const Real defaultConst_
 Default constant value (Real(0)).
Real default_
 Default non constant value.

Detailed Description

Declaration of the lower triangular matrix class.

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 55 of file STK_MatrixLowerTriangular.h.


Member Typedef Documentation

Real for the Interface Class.

Definition at line 66 of file STK_MatrixLowerTriangular.h.


Constructor & Destructor Documentation

STK::MatrixLowerTriangular::MatrixLowerTriangular ( Range const &  I = Range(),
Range const &  J = Range() 
)

Default constructor Default is I=(1:0) and J=(1:0)

Parameters:
Irange of the Rows
Jrange of the Cols

Definition at line 44 of file STK_MatrixLowerTriangular.cpp.

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

Referenced by get2D().

                                            : _IArray2DType(I, J)
                                            , defaultConst_(Real())
{
  // initialize vertically the container
  this->initializeCols(J);
}
STK::MatrixLowerTriangular::MatrixLowerTriangular ( Range const &  I,
Range const &  J,
Real const &  v 
)

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

Parameters:
Irange of the Rows
Jrange of the Cols
vinitial value in the container

Definition at line 58 of file STK_MatrixLowerTriangular.cpp.

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

                                            : _IArray2DType(I, J)
                                            , defaultConst_(Real())
{
  // initialize vertically the container
  this->initializeCols(J);
  // initialize with v
  for (Integer j = J.first(); j <= J.last(); j++)
  {
    Real* p(this->data(j));
    Integer beg(this->rangeCols_[j].first());
    Integer end(this->rangeCols_[j].last());

    for (Integer i = beg; i <= end; i++) p[i] = v;
  }
}
STK::MatrixLowerTriangular::MatrixLowerTriangular ( const MatrixLowerTriangular T,
bool  ref = false 
)

Copy constructor.

Parameters:
Tthe container to copy
reftrue if T is wrapped

Definition at line 82 of file STK_MatrixLowerTriangular.cpp.

References STK::IArrayBase< DATA >::data(), STK::IArrayBase< Real * >::data(), STK::IContainer2D::firstCol(), STK::IContainer2D::firstRow(), STK::IArray2D< Real, MatrixLowerTriangular >::initializeCols(), STK::IContainer2D::lastCol(), STK::IContainer2D::lastRow(), pt(), and STK::IContainer2D::rangeHo().

                                            : _IArray2DType(T, ref)
                                            , defaultConst_(Real())
{
  if (!ref)
  {
    // initialize vertically the container
    this->initializeCols(T.rangeHo());
    // initialize with T
    for (Integer j=T.firstCol(); j<=T.lastCol(); j++)
    {
      Real* p(this->data(j));
      const Real* pt= T.data(j);

      for (Integer i=T.firstRow(); i<=T.lastRow(); i++) p[i]= pt[i];
    }
  }
}
STK::MatrixLowerTriangular::MatrixLowerTriangular ( const _IArray2DType T,
Range const &  I,
Range const &  J 
)

constructor by reference, ref_=1.

Parameters:
Tthe container to wrap
Irange of the Rows to wrap
Jrange of the Cols to wrap

Definition at line 108 of file STK_MatrixLowerTriangular.cpp.

                                            : _IArray2DType(T, I, J)
                                            , defaultConst_(Real())
{ ;}
STK::MatrixLowerTriangular::MatrixLowerTriangular ( Real **  q,
Range const &  I,
Range const &  J 
)

Wrapper constructor Contruct a reference container.

Parameters:
qpointer on the data
Irange of the Rows to wrap
Jrange of the Cols to wrap

Definition at line 121 of file STK_MatrixLowerTriangular.cpp.

                                            : _IArray2DType(q, I, J)
                                            , defaultConst_(Real())
{ ;}
STK::MatrixLowerTriangular::~MatrixLowerTriangular ( ) [virtual]

virtual destructor : use destructor of Array2D.

Definition at line 131 of file STK_MatrixLowerTriangular.cpp.

{ ;}

Member Function Documentation

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

Compute the first index of the column icol.

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

Definition at line 109 of file STK_MatrixLowerTriangular.h.

References STK::IContainer2D::firstCol(), STK::IContainer2D::firstRow(), and STK::max().

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

    {
      return max( this->firstRow()+ icol - this->firstCol(), this->firstRow());
    }
Integer STK::MatrixLowerTriangular::compLastVe ( Integer const &  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:
icolthe column we want to know the last index

Definition at line 118 of file STK_MatrixLowerTriangular.h.

References STK::IContainer2D::lastRow().

    {
      return this->lastRow();
    }
Integer STK::MatrixLowerTriangular::compSizeVe ( Integer const &  icol) const [inline]

Compute the size of the column icol.

Parameters:
icolthe column we want to know the size

Definition at line 126 of file STK_MatrixLowerTriangular.h.

References compFirstVe(), STK::IContainer2D::lastRow(), and STK::max().

    {
      return max(this->lastRow()-compFirstVe(icol)+1, Integer(0));
    }
Range STK::MatrixLowerTriangular::compRangeVe ( Integer const &  icol) const [inline]

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

Parameters:
icolthe number of the column to compute the range

Definition at line 135 of file STK_MatrixLowerTriangular.h.

References compFirstVe(), and STK::IContainer2D::lastRow().

Referenced by col().

    {
      return Range(compFirstVe(icol), this->lastRow());
    }
Integer STK::MatrixLowerTriangular::compFirstHo ( Integer const &  irow) const [inline]

compute the beginning of the row irow.

Parameters:
irowthe column to compute the beginning

Definition at line 143 of file STK_MatrixLowerTriangular.h.

References STK::IContainer2D::firstCol().

    {
      return this->firstCol();
    }
Integer STK::MatrixLowerTriangular::compLastHo ( Integer const &  irow) const [inline]

compute the end of the row irow.

Parameters:
irowthe column to compute the end

Definition at line 151 of file STK_MatrixLowerTriangular.h.

References STK::IContainer2D::firstCol(), STK::IContainer2D::firstRow(), STK::IContainer2D::lastCol(), and STK::min().

Referenced by compRangeHo(), and compSizeHo().

    {
      return min( this->firstCol()+ irow - this->firstRow(),
                 this->lastCol());
    }
Integer STK::MatrixLowerTriangular::compSizeHo ( Integer const &  irow) const [inline]

compute the true number of element of the row irow.

Parameters:
irowthe number of the column to compute the size

Definition at line 160 of file STK_MatrixLowerTriangular.h.

References compLastHo(), STK::IContainer2D::firstCol(), and STK::max().

    {
      return max(compLastHo(irow)-this->firstCol()+1, Integer(0));
    }
Range STK::MatrixLowerTriangular::compRangeHo ( Integer const &  irow) const [inline]

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

Parameters:
irowthe number of the row to compute the range

Definition at line 169 of file STK_MatrixLowerTriangular.h.

References compLastHo(), and STK::IContainer2D::firstCol().

Referenced by row().

    {
      return Range(this->firstCol(), this->compLastHo(irow));
    }
bool STK::MatrixLowerTriangular::isInside ( Integer const &  i,
Integer const &  j 
) const [inline]

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

Parameters:
ithe number of the row
jthe number of the col

Definition at line 179 of file STK_MatrixLowerTriangular.h.

References compFirstVe().

Referenced by elt().

    {
      return (i>=compFirstVe(j));
    }
Real& STK::MatrixLowerTriangular::elt ( Integer  i,
Integer  j 
) [inline]

access to one element.

Parameters:
iindex of the row
jindex of the col

Definition at line 188 of file STK_MatrixLowerTriangular.h.

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

    {
      return isInside(i, j) ? this->data(j)[i] : default_;
    }
Real const& STK::MatrixLowerTriangular::elt ( Integer  i,
Integer  j 
) const [inline]

access to one element const.

Parameters:
iindex of the row
jindex of the col

Definition at line 197 of file STK_MatrixLowerTriangular.h.

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

    {
      if (isInside(i, j))
      {
        return this->data(j)[i];
      }
      else
      {
        return defaultConst_;
      }
    }
MatrixLowerTriangular STK::MatrixLowerTriangular::get2D ( Range const &  I,
Range const &  J 
) const [inline]

access to a sub-array.

Parameters:
Irange of the rows
Jrange of the cols

Definition at line 213 of file STK_MatrixLowerTriangular.h.

References MatrixLowerTriangular().

    {
      return MatrixLowerTriangular(*this, I, J);
    }
Vector STK::MatrixLowerTriangular::col ( Range const &  I,
Integer  j 
) const [inline]

access to a part of a column.

Parameters:
Irange of the rows
jindex of the col
Returns:
a reference in the range I of the column j of this

Definition at line 223 of file STK_MatrixLowerTriangular.h.

References compRangeVe(), STK::IArrayBase< Real * >::data(), and STK::Range::inf().

    {
      return Vector( this->data(j), Range::inf(I, compRangeVe(j)), j);
    }
Vector STK::MatrixLowerTriangular::col ( Integer  j) const [inline]

access to a part of a column.

Parameters:
jindex of the column
Returns:
a reference in the range I of the column j of this

Reimplemented from STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >.

Definition at line 232 of file STK_MatrixLowerTriangular.h.

References compRangeVe(), and STK::IArrayBase< Real * >::data().

    {
      return Vector( this->data(j), compRangeVe(j), j);
    }
Point STK::MatrixLowerTriangular::row ( Integer  i,
Range const &  J 
) const [inline]

access to a part of a row.

Parameters:
iindex of the row
Jrange of the columns
Returns:
a reference of the row i.

Definition at line 242 of file STK_MatrixLowerTriangular.h.

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

    {
      return Point(*this, Range::inf(J, compRangeHo(i)), i);
    }
Point STK::MatrixLowerTriangular::row ( Integer  i) const [inline]

access to a part of a row.

Parameters:
iindex of the row
Returns:
a reference of the row i.

Reimplemented from STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >.

Definition at line 251 of file STK_MatrixLowerTriangular.h.

References compRangeHo().

    {
      return Point(*this, compRangeHo(i), i);
    }
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:
Tthe container to copy

Definition at line 141 of file STK_MatrixLowerTriangular.cpp.

References STK::IArrayBase< DATA >::data(), STK::IArrayBase< Real * >::data(), STK::ITContainer1D< TYPE, TContainer1D >::first(), STK::IContainer2D::firstCol(), STK::IArray2D< Real, MatrixLowerTriangular >::initialize(), STK::IContainer2D::lastCol(), pt(), STK::IArray2DBase< TYPE, PTRCOL, TArrayHo, TArrayVe, TArray2D >::rangeCols_, STK::IArray2DBase< Real, Real *, ArrayHo< Real >, Array1D< Real >, MatrixLowerTriangular >::rangeCols_, STK::IContainer2D::rangeHo(), STK::IContainer2D::rangeVe(), STK::IContainer2D::sizeHo(), and STK::IContainer2D::sizeVe().

{
  // Resize if necessary.
  if ( (this->sizeVe() != T.sizeVe())||(this->sizeHo() != T.sizeHo()))
  {
    this->initialize(T.rangeVe(), T.rangeHo());
  }
  // coopy without overlapping
  if (T.firstCol()>=this->firstCol())
  {
    for ( Integer jt=T.firstCol(), j=this->firstCol()
        ; jt<=T.lastCol()
        ; j++, jt++)
    {
      Real* p(this->data(j));
      const Real* pt= T.data(jt);
      Integer beg(this->rangeCols_[j].first());
      Integer end(this->rangeCols_[j].last());
      Integer tbeg(T.rangeCols_[j].first());

      for (Integer i=beg, it=tbeg; i<=end; i++, it++)
        p[i]= pt[it];
    }
    return *this;
  }
  // T.firstCol()<this->firstCol()
  for ( Integer jt=T.lastCol(), j=this->lastCol()
      ; jt>=T.firstCol()
      ; j--, jt--)
  {
    Real* p(this->data(j));
    const Real* pt= T.data(jt);
    Integer beg(this->rangeCols_[j].first());
    Integer end(this->rangeCols_[j].last());
    Integer tbeg(T.rangeCols_[j].first());

    for (Integer i=beg, it=tbeg; i<=end; i++, it++)
      p[i]= pt[it];
  }
  return *this;
}
MatrixLowerTriangular& STK::MatrixLowerTriangular::operator= ( Real const &  v) [inline]

operator= : set the container to a constant value.

Parameters:
vthe value to set

Definition at line 267 of file STK_MatrixLowerTriangular.h.

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

    {
      for (Integer j=this->firstCol(); j<=this->lastCol(); j++)
      {
        Real* p(this->data(j));
        Integer beg(this->rangeCols_[j].first());
        Integer end(this->rangeCols_[j].last());

        for (Integer i=beg; i<=end; i++) p[i]= v;
      }
      return *this;
    }

Member Data Documentation

Default constant value (Real(0)).

Definition at line 59 of file STK_MatrixLowerTriangular.h.

Referenced by elt().

Default non constant value.

Definition at line 62 of file STK_MatrixLowerTriangular.h.

Referenced by elt().


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