STK++ 1.0

STK::MatrixUpperTriangular Class Reference

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

#include <STK_MatrixUpperTriangular.h>

Inheritance diagram for STK::MatrixUpperTriangular:

List of all members.

Public Types

typedef Array1D< RealVector
 Column Real.
typedef ArrayHo< RealPoint
 Row Real.
typedef IArrayBase< Real * > _IArrayBaseType
 Real for the Base reference Class.
typedef IArray2D< Real,
MatrixUpperTriangular
_IArray2DType
 Real for the Interface Class.

Public Member Functions

 MatrixUpperTriangular (Range const &I=Range(), Range const &J=Range())
 Default constructor Default is I=(1:0) and J=(1:0).
 MatrixUpperTriangular (Range const &I, Range const &J, Real const &v)
 constructor with rangeVe_ and rageHo_ specified, initialization with a specified value.
 MatrixUpperTriangular (const MatrixUpperTriangular &T, bool ref=false)
 Copy constructor.
 MatrixUpperTriangular (const _IArray2DType &T, Range const &I, Range const &J)
 constructor by reference in a given range, ref_=1.
 MatrixUpperTriangular (Real **q, Range const &I, Range const &J)
 Wrapper constructor Contruct a reference container.
virtual ~MatrixUpperTriangular ()
 virtual destructor.
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.
Integer compFirstVe (Integer const &icol) const
 compute the begin of the column icol.
Integer compLastVe (Integer const &icol) const
 compute the end of the column icol.
Integer compSizeVe (Integer const &icol) const
 compute the true number of element of the column icol.
Range compRangeVe (Integer const &icol) const
 compute the range of the effectively stored elements in the col icol.
bool isInside (Integer const &i, Integer const &j) const
 private function for determining if the element i of the col j is in the upper triangular part.
Realelt (Integer i, Integer j)
 access to one element.
Real const & elt (Integer i, Integer j) const
 access to one element const.
MatrixUpperTriangular 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.
MatrixUpperTriangularoperator= (const MatrixUpperTriangular &T)
 Operator = : overwrite the MatrixUpperTriangular with T.
MatrixUpperTriangularoperator= (Real const &v)
 Operator = : overwrite with a constant value.

Private Attributes

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

Detailed Description

Declaration of the upper triangular matrix class.

A MatrixUpperTriangular is a column oriented 2D upper 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 upper triangular again using the method IArray2D::update().

Definition at line 55 of file STK_MatrixUpperTriangular.h.


Member Typedef Documentation

Column Real.

Definition at line 66 of file STK_MatrixUpperTriangular.h.

Row Real.

Definition at line 69 of file STK_MatrixUpperTriangular.h.

Real for the Base reference Class.

Reimplemented from STK::IArray2D< Real, MatrixUpperTriangular >.

Definition at line 72 of file STK_MatrixUpperTriangular.h.

Real for the Interface Class.

Definition at line 76 of file STK_MatrixUpperTriangular.h.


Constructor & Destructor Documentation

STK::MatrixUpperTriangular::MatrixUpperTriangular ( 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_MatrixUpperTriangular.cpp.

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

Referenced by get2D().

                                            : _IArray2DType(I, J)
                                            , defaultConst_(Real())
{
  // initialize vertically the container
  this->initializeCols(J);
}
STK::MatrixUpperTriangular::MatrixUpperTriangular ( 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_MatrixUpperTriangular.cpp.

References STK::IArrayBase< Real * >::data(), STK::Range::first(), STK::IArray2D< Real, MatrixUpperTriangular >::initializeCols(), STK::Range::last(), and STK::IArray2DBase< Real, Real *, ArrayHo< Real >, Array1D< Real >, MatrixUpperTriangular >::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::MatrixUpperTriangular::MatrixUpperTriangular ( const MatrixUpperTriangular T,
bool  ref = false 
)

Copy constructor.

Parameters:
Tthe container to copy
reftrue if T is wrapped

Definition at line 82 of file STK_MatrixUpperTriangular.cpp.

References STK::IArrayBase< DATA >::data(), STK::IArrayBase< Real * >::data(), STK::IContainer2D::firstCol(), STK::IContainer2D::firstRow(), STK::IArray2D< Real, MatrixUpperTriangular >::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::MatrixUpperTriangular::MatrixUpperTriangular ( const _IArray2DType T,
Range const &  I,
Range const &  J 
)

constructor by reference in a given range, 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_MatrixUpperTriangular.cpp.

                                            : _IArray2DType(T, I, J)
                                            , defaultConst_(Real())
{ ;}
STK::MatrixUpperTriangular::MatrixUpperTriangular ( 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_MatrixUpperTriangular.cpp.

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

virtual destructor.

Definition at line 130 of file STK_MatrixUpperTriangular.cpp.

{ ;}

Member Function Documentation

Integer STK::MatrixUpperTriangular::compFirstHo ( Integer const &  irow) const [inline]

compute the beginning of the row irow.

Parameters:
irowthe row to compute the begining

Definition at line 123 of file STK_MatrixUpperTriangular.h.

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

Referenced by compRangeHo(), and compSizeHo().

    {
      return max( this->firstCol() + irow - this->firstRow()
                , this->firstCol()
                );
    }
Integer STK::MatrixUpperTriangular::compLastHo ( Integer const &  irow) const [inline]

compute the end of the row irow.

Parameters:
irowthe row to compute the beginning

Definition at line 133 of file STK_MatrixUpperTriangular.h.

References STK::IContainer2D::lastCol().

    {
      return this->lastCol();
    }
Integer STK::MatrixUpperTriangular::compSizeHo ( Integer const &  irow) const [inline]

compute the true number of element of the row irow.

Parameters:
irowthe index of the row we want to compute the size

Definition at line 141 of file STK_MatrixUpperTriangular.h.

References compFirstHo(), STK::IContainer2D::lastCol(), and STK::max().

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

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

Parameters:
irowthe number of the row we want to compute the range

Definition at line 150 of file STK_MatrixUpperTriangular.h.

References compFirstHo(), and STK::IContainer2D::lastCol().

Referenced by row().

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

compute the begin of the column icol.

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

Definition at line 158 of file STK_MatrixUpperTriangular.h.

References STK::IContainer2D::firstRow().

    {
      return this->firstRow();
    }
Integer STK::MatrixUpperTriangular::compLastVe ( Integer const &  icol) const [inline]

compute the end of the column icol.

Parameters:
icolthe row to compute the end

Definition at line 166 of file STK_MatrixUpperTriangular.h.

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

Referenced by compRangeVe(), and compSizeVe().

    {
      return min( this->firstRow() + icol - this->firstCol()
                , this->lastRow()
                );
    }
Integer STK::MatrixUpperTriangular::compSizeVe ( Integer const &  icol) const [inline]

compute the true number of element of the column icol.

Parameters:
icolthe number of the column to compute the size

Definition at line 176 of file STK_MatrixUpperTriangular.h.

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

    {
      return max(compLastVe(icol) - this->firstRow() + 1, (Integer )0);
    }
Range STK::MatrixUpperTriangular::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 185 of file STK_MatrixUpperTriangular.h.

References compLastVe(), and STK::IContainer2D::firstRow().

Referenced by col(), STK::Qr::insertCol(), and STK::Qr::pushBackCol().

    {
      return Range(this->firstRow(), this->compLastVe(icol));
    }
bool STK::MatrixUpperTriangular::isInside ( Integer const &  i,
Integer const &  j 
) const [inline]

private function for determining if the element i of the col j is in the upper triangular part.

Definition at line 193 of file STK_MatrixUpperTriangular.h.

References STK::IArray2DBase< Real, Real *, ArrayHo< Real >, Array1D< Real >, MatrixUpperTriangular >::rangeCols_.

Referenced by elt().

   { return (i<=this->rangeCols_[j].last());}
Real& STK::MatrixUpperTriangular::elt ( Integer  i,
Integer  j 
) [inline]

access to one element.

Definition at line 197 of file STK_MatrixUpperTriangular.h.

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

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

access to one element const.

Definition at line 201 of file STK_MatrixUpperTriangular.h.

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

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

access to a sub-array.

Definition at line 207 of file STK_MatrixUpperTriangular.h.

References MatrixUpperTriangular().

    { return MatrixUpperTriangular(*this, I, J);}
Vector STK::MatrixUpperTriangular::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 215 of file STK_MatrixUpperTriangular.h.

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

    {
      return Vector( this->data(j), Range::inf(I, compRangeVe(j)), j);
    }
Vector STK::MatrixUpperTriangular::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 >, MatrixUpperTriangular >.

Definition at line 224 of file STK_MatrixUpperTriangular.h.

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

    {
      return Vector( this->data(j), compRangeVe(j), j);
    }
Point STK::MatrixUpperTriangular::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 234 of file STK_MatrixUpperTriangular.h.

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

    {
      return Point(*this, Range::inf(J, compRangeHo(i)), i);
    }
Point STK::MatrixUpperTriangular::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 >, MatrixUpperTriangular >.

Definition at line 243 of file STK_MatrixUpperTriangular.h.

References compRangeHo().

    {
      return Point(*this, compRangeHo(i), i);
    }
MatrixUpperTriangular & STK::MatrixUpperTriangular::operator= ( const MatrixUpperTriangular T)

Operator = : overwrite the MatrixUpperTriangular with T.

Definition at line 139 of file STK_MatrixUpperTriangular.cpp.

References STK::IArrayBase< DATA >::data(), STK::IArrayBase< Real * >::data(), STK::ITContainer1D< TYPE, TContainer1D >::first(), STK::IContainer2D::firstCol(), STK::IArray2D< Real, MatrixUpperTriangular >::initialize(), STK::IContainer2D::lastCol(), pt(), STK::IArray2DBase< TYPE, PTRCOL, TArrayHo, TArrayVe, TArray2D >::rangeCols_, STK::IArray2DBase< Real, Real *, ArrayHo< Real >, Array1D< Real >, MatrixUpperTriangular >::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;
}
MatrixUpperTriangular& STK::MatrixUpperTriangular::operator= ( Real const &  v) [inline]

Operator = : overwrite with a constant value.

Definition at line 253 of file STK_MatrixUpperTriangular.h.

References STK::IArrayBase< Real * >::data(), STK::IContainer2D::firstCol(), STK::IContainer2D::lastCol(), and STK::IArray2DBase< Real, Real *, ArrayHo< Real >, Array1D< Real >, MatrixUpperTriangular >::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_MatrixUpperTriangular.h.

Referenced by elt().

Default non constant value.

Definition at line 62 of file STK_MatrixUpperTriangular.h.

Referenced by elt().


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