STK++ 1.0

STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D > Class Template Reference

Interface class for homogeneous 2D containers. More...

#include <STK_ITContainer2D.h>

Inheritance diagram for STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >:

List of all members.

Public Member Functions

virtual ~ITContainer2D ()
 virtual destructor.
TYPE & operator() (Integer const &i, const Integer j)
 Operator () : access to one element.
TYPE const & operator() (Integer i, Integer j) const
 Operator () : access to one constant element.
TContainerVe operator[] (Integer j) const
 Operator [] : access to one column.
TContainerVe col (Integer j) const
 access to one column.
TContainerVe operator() (Range const &I, Integer j) const
 Operator () : access to many elements of a column.
TContainerHo operator() (Integer i) const
 Operator () : access to one row.
TContainerHo row (Integer i) const
 Operator () : access to one row.
TContainerHo operator() (Integer i, Range const &J) const
 Operator () : access to many elements of a row.
TContainer2D operator() (Range const &I, Range const &J) const
 Operator () : access to a sub-array.
TContainer2D operator() (Range const &I) const
 Operator () : access to many rows.
TContainer2D operator[] (Range const &J) const
 Operator [] : access to many columns.
TYPE & at (Integer i, Integer j)
 return safely the element (i, j).
TYPE const & at (Integer i, Integer j) const
 return safely the constant element (i, j).
TContainer2D at (Range const &I, Range const &J) const
 STL compatibility : return a sub-Array.
TContainerVe at (Range const &I, Integer j) const
 STL compatibility : return a part of the column j in the range I.
TContainerHo at (Integer i, Range const &J) const
 STL compatibility : return a part of the row i in the range J.
TContainerVe atCol (Integer j) const
 STL compatibility : return the column j.
TContainer2D atCol (Range const &J) const
 STL compatibility : return the Container2D in column range J.
TContainerHo atRow (Integer i) const
 STL compatibility : return the row i.
TContainer2D atRow (Range const &I) const
 STL compatibility : return the Container2D in the row range I.
template<class Container1D >
void pushBackCol (ITContainer1D< TYPE, Container1D > const &V)
 push back a column to the container with value V.

Protected Member Functions

 ITContainer2D (Range const &I=Range(), Range const &J=Range())
 Default constructor.
 ITContainer2D (const ITContainer2D &T)
 Copy constructor.

Detailed Description

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
class STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >

Interface class for homogeneous 2D containers.

Use the curious recursive template paradigm : the template parameter TContainer2D is the name of the class that implements the interface ITContainer2D. For example

 template<class TYPE>
 class TContainer2D : public ITContainer2D< TYPE
                                          , TContainerHo
                                          , TContainerVe
                                          , TContainer2D<TYPE>
                                          >
 {...}

the pseudo virtual function defined in this interface have the following definition:

   TContainerVe col( Range const& I, Integer j) const;
   TContainerHo row( Integer const& i, Range const& J) const;
   TContainer2D get2D( Range const& I, Range const& J) const;

A TContainerVe is a class that allow to access to (or a part of) a column of the TContainer2D class

A TContainerHo is a class that allow to access to (or a part of) a a row of the TContainer2D class.

Definition at line 84 of file STK_ITContainer2D.h.


Constructor & Destructor Documentation

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::ITContainer2D ( Range const &  I = Range(),
Range const &  J = Range() 
) [inline, protected]

Default constructor.

Default values are rangeHo=(1:0) and rangeVe=(1:0).

Parameters:
Ithe vertical range
Jthe horizontal range

Definition at line 91 of file STK_ITContainer2D.h.

                 : ITContainer2DBase<TYPE, TContainer2D>(I, J)
    { }
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::ITContainer2D ( const ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D > &  T) [inline, protected]

Copy constructor.

Parameters:
Tthe container to copy

Definition at line 98 of file STK_ITContainer2D.h.

                 : ITContainer2DBase<TYPE, TContainer2D>(T)
    { }
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
virtual STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::~ITContainer2D ( ) [inline, virtual]

virtual destructor.

Definition at line 104 of file STK_ITContainer2D.h.

{ ;}

Member Function Documentation

template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TYPE& STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::operator() ( Integer const &  i,
const Integer  j 
) [inline]

Operator () : access to one element.

Parameters:
iindex of the row
jindex of the column
Returns:
the element (i,j) of the 2D container.

Reimplemented from STK::ITContainer2DBase< TYPE, TContainer2D >.

Definition at line 111 of file STK_ITContainer2D.h.

    { return this->asLeaf().elt(i,j);}
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TYPE const& STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::operator() ( Integer  i,
Integer  j 
) const [inline]

Operator () : access to one constant element.

Parameters:
iindex of the row
jindex of the column
Returns:
a constant element (i,j) of the 2D container.

Reimplemented from STK::ITContainer2DBase< TYPE, TContainer2D >.

Definition at line 119 of file STK_ITContainer2D.h.

    { return this->asLeaf().elt(i,j);}
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainerVe STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::operator[] ( Integer  j) const [inline]

Operator [] : access to one column.

Parameters:
jindex of the column
Returns:
a Vertical container containing the column j of the Container

Definition at line 126 of file STK_ITContainer2D.h.

    { return this->asLeaf().col(j);}
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainerVe STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::col ( Integer  j) const [inline]
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainerVe STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::operator() ( Range const &  I,
Integer  j 
) const [inline]

Operator () : access to many elements of a column.

Parameters:
Irange of the index of the rows
jindex of the col
Returns:
a Vertical container containing the column j of the Container in the range I

Definition at line 142 of file STK_ITContainer2D.h.

    { return this->asLeaf().col(I, j);}
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainerHo STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::operator() ( Integer  i) const [inline]

Operator () : access to one row.

Parameters:
iindex of the row
Returns:
an Horizontal container containing the row i of the Container

Definition at line 149 of file STK_ITContainer2D.h.

    { return this->asLeaf().row(i);}
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainerHo STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::row ( Integer  i) const [inline]

Operator () : access to one row.

Parameters:
iindex of the row
Returns:
an Horizontal container containing the row i of the Container

Reimplemented in STK::MatrixLowerTriangular, and STK::MatrixUpperTriangular.

Definition at line 156 of file STK_ITContainer2D.h.

Referenced by STK::ITStatModel< Real, Point, Vector, Matrix >::compLogLikelihood().

    { return this->asLeaf().row(i);}
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainerHo STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::operator() ( Integer  i,
Range const &  J 
) const [inline]

Operator () : access to many elements of a row.

Parameters:
iindex of the row
Jindex of the col
Returns:
an Horizontal container containing the row i of the Container in the range J

Definition at line 165 of file STK_ITContainer2D.h.

    { return this->asLeaf().row(i, J);}
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainer2D STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::operator() ( Range const &  I,
Range const &  J 
) const [inline]

Operator () : access to a sub-array.

Parameters:
Irange of the index of the rows
Jrange of the index of the cols
Returns:
a 2D container containing the Container in the range I, J

Definition at line 173 of file STK_ITContainer2D.h.

    { return this->asLeaf().get2D(I, J);}
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainer2D STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::operator() ( Range const &  I) const [inline]

Operator () : access to many rows.

Parameters:
Irange of the index of the rows
Returns:
a 2D container containing the Container in the vertical range I

Definition at line 181 of file STK_ITContainer2D.h.

    { return this->asLeaf().get2D(I, this->rangeHo());}
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainer2D STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::operator[] ( Range const &  J) const [inline]

Operator [] : access to many columns.

Parameters:
Jrange of the index of the cols
Returns:
a 2D container containing the Container in the Horizontal range J

Definition at line 189 of file STK_ITContainer2D.h.

    { return this->asLeaf().get2D(this->rangeVe(), J);}
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TYPE& STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::at ( Integer  i,
Integer  j 
) [inline]

return safely the element (i, j).

Parameters:
iindex of the row
jindex of the col
Returns:
the element (i,j) of the 2D container.

Reimplemented from STK::ITContainer2DBase< TYPE, TContainer2D >.

Definition at line 197 of file STK_ITContainer2D.h.

    {
      if (this->firstRow() > i)
      { throw std::out_of_range("ITContainer2DBase::at(i, j) "
                                "this->firstRow() > i");
      }
      if (this->lastRow() < i)
      { throw std::out_of_range("ITContainer2DBase::at(i, j) "
                                "this->lastRow() < i");
      }
      if (this->firstCol() > j)
      { throw std::out_of_range("ITContainer2DBase::at(i, j) "
                                "this->firstCol() > j");
      }
      if (this->lastCol() < j)
      { throw std::out_of_range("ITContainer2DBase::at(i, j) "
                                "this->lastCol() < j");
      }
      return this->asLeaf().elt(i, j);
    }
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TYPE const& STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::at ( Integer  i,
Integer  j 
) const [inline]

return safely the constant element (i, j).

Parameters:
iindex of the row
jindex of the col
Returns:
the constant element (i,j) of the 2D container.

Reimplemented from STK::ITContainer2DBase< TYPE, TContainer2D >.

Definition at line 223 of file STK_ITContainer2D.h.

    {
      // check bounds
      if (this->firstRow() > i)
      { throw std::out_of_range("ITContainer2DBase::at(i, j) "
                                "this->firstRow() > i");
      }
      if (this->lastRow() < i)
      { throw std::out_of_range("ITContainer2DBase::at(i, j) "
                                "this->lastRow() < i");
      }
      if (this->firstCol() > j)
      { throw std::out_of_range("ITContainer2DBase::at(i, j) "
                                "this->firstCol() > j");
      }
      if (this->lastCol() < j)
      { throw std::out_of_range("ITContainer2DBase::at(i, j) "
                                "this->lastCol() < j");
      }
      // return element
      return this->asLeaf().elt(i, j);
    }
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainer2D STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::at ( Range const &  I,
Range const &  J 
) const [inline]

STL compatibility : return a sub-Array.

Parameters:
Irange of the index of the rows
Jrange of the index of the cols

Definition at line 250 of file STK_ITContainer2D.h.

    {
      if (this->firstRow() > I.first())
      { throw std::out_of_range("ITContainer2D::at(I, J) "
                                "this->firstRow() > I.first()");
      }
      if (this->lastRow() < I.last())
      { throw std::out_of_range("ITContainer2D::at(I, J) "
                                "this->lastRow() < I.last()");
      }
      if (this->firstCol() > J.first())
      { throw std::out_of_range("ITContainer2D::at(I, J) "
                                "this->firstCol() > J.first()");
      }
      if (this->lastCol() < J.last())
      { throw std::out_of_range("ITContainer2D::at(I, J) "
                                "this->lastCol() < J.last()");
      }
      return this->asLeaf().get2D(I, J);
    }
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainerVe STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::at ( Range const &  I,
Integer  j 
) const [inline]

STL compatibility : return a part of the column j in the range I.

Parameters:
Irange of the index of the rows
jindex of the col

Definition at line 275 of file STK_ITContainer2D.h.

    {
      if (this->firstRow() > I.first())
      { throw std::out_of_range("TContainer2D::at(I, j) "
                           "this->firstRow() > I.first()");
      }
      if (this->lastRow() < I.last())
      { throw std::out_of_range("TContainer2D::at(I, j) "
                           "this->lastRow() < I.last()");
      }
      if (this->firstCol() > j)
      { throw std::out_of_range("TContainer2D::at(I, j) "
                           "this->firstCol() > j");
      }
      if (this->lastCol() < j)
      { throw std::out_of_range("TContainer2D::at(I, j) "
                           "this->lastCol() < j");
      }
      return this->asLeaf().col(I, j);
    }
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainerHo STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::at ( Integer  i,
Range const &  J 
) const [inline]

STL compatibility : return a part of the row i in the range J.

Parameters:
iindex of the row
Jrange of the index of the cols

Definition at line 300 of file STK_ITContainer2D.h.

    {
      if (this->firstRow() > i)
      { throw std::out_of_range("TContainer2D::at(i, J) "
                           "this->firstRow() > i");
      }
      if (this->lastRow() < i)
      { throw std::out_of_range("TContainer2D::at(i, J) "
                           "this->lastRow() < i");
      }
      if (this->firstCol() > J.first())
      { throw std::out_of_range("TContainer2D::at(i, J) "
                           "this->firstCol() > J.first()");
      }
      if (this->lastCol() < J.last())
      { throw std::out_of_range("TContainer2D::at(i, J) "
                           "this->lastCol() < J.last()");
      }
      return this->asLeaf().row(J, i);
    }
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainerVe STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::atCol ( Integer  j) const [inline]

STL compatibility : return the column j.

Parameters:
jindex of the col

Definition at line 324 of file STK_ITContainer2D.h.

    {
      if (this->firstCol() > j)
      { throw std::out_of_range("TContainer2D::atCol(j) "
                           "this->firstCol() > j");
      }
      if (this->lastCol() < j)
      { throw std::out_of_range("TContainer2D::atCol(j) "
                           "this->lastCol() < j");
      }
      return this->asLeaf().col(this->rangeVe(), j);
    }
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainer2D STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::atCol ( Range const &  J) const [inline]

STL compatibility : return the Container2D in column range J.

Parameters:
Jrange of the index of the cols

Definition at line 340 of file STK_ITContainer2D.h.

    {
      if (this->firstCol() > J.first())
      { throw std::out_of_range("TContainer2D::atCol(J) "
                                "this->firstCol() > J.first()");
      }
      if (this->lastCol() < J.last())
      { throw std::out_of_range("TContainer2D::atCol(J) "
                                "this->lastCol() < J.last()");
      }
      return this->asLeaf().get2D(this->rangeVe(), J);
    }
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainerHo STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::atRow ( Integer  i) const [inline]

STL compatibility : return the row i.

Parameters:
ithe index of the row

Definition at line 356 of file STK_ITContainer2D.h.

    {
      if (this->firstRow() > i)
      { throw std::out_of_range("TContainer2D::atRow(i) "
                                "this->firstRow() > i");
      }
      if (this->lastRow() < i)
      { throw std::out_of_range("TContainer2D::atRow(i) "
                                "this->lastRow() < i");
      }
      return this->asLeaf().row(i, this->rangeHo());
    }
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
TContainer2D STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::atRow ( Range const &  I) const [inline]

STL compatibility : return the Container2D in the row range I.

Parameters:
Irange of the index of the rows

Definition at line 372 of file STK_ITContainer2D.h.

    {
      if (this->firstRow() > I.first())
      { throw std::out_of_range("TContainer2D::atRow(I) "
                                "this->firstRow() > I.first()");
      }
      if (this->lastRow() < I.last())
      { throw std::out_of_range("TContainer2D::atRow(I) "
                                "this->lastRow() < I.last()");
      }
      return this->asLeaf().get2D(I, this->rangeHo());
    }
template<class TYPE, class TContainerHo, class TContainerVe, class TContainer2D>
template<class Container1D >
void STK::ITContainer2D< TYPE, TContainerHo, TContainerVe, TContainer2D >::pushBackCol ( ITContainer1D< TYPE, Container1D > const &  V) [inline]

push back a column to the container with value V.

Parameters:
Vthe values to add to the end of the container

Definition at line 389 of file STK_ITContainer2D.h.

    {
      const Integer firstRow = V.first(), lastRow = V.last();
      // check if the container is empty
      if (this->empty())
      {
        this->resize(V.range(), Range(1));
        for (Integer i=firstRow; i<=lastRow; i++)
          (*this)(i, 1) = V[i];
        return;
      }
#ifdef STK_BOUNDS_CHECK
      if (V.range() != this->rangeVe())
      { throw std::runtime_error("TContainer2D::pushBackCol(V) "
                                 "V.range() != this->rangeVe()");
      }
#endif
      // if the container is not empty we add a column and copy V inside
      this->pushBackCols();
      const Integer lastCol = this->lastCol();
      for (Integer i=firstRow; i<=lastRow; i++)
        (*this)(i, lastCol) = V[i];
    }

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