|
STK++ 1.0
|
Specialization of the Array2D class for Real values. More...
#include <STK_Matrix.h>

Public Types | |
| typedef IArray2D< Real, Array2D< Real > > | _IArray2DType |
| Type for the Interface base Class. | |
Public Member Functions | |
| Array2D (Range const &I=Range(), Range const &J=Range()) | |
| Default constructor. | |
| Array2D (Range const &I, Range const &J, Real const &v) | |
| constructor with rbeg, rend, cbeg and cend specified, initialization with a constant. | |
| Array2D (const Array2D &T, bool ref=false) | |
| Copy constructor. | |
| Array2D (const Array2D &T, Range const &I, Range const &J) | |
| constructor by reference, ref_=1. | |
| Array2D (Real **q, Range const &I, Range const &J) | |
| Wrapper constructor Contruct a reference container. | |
| virtual | ~Array2D () |
| virtual destructor. | |
| Real & | elt (Integer i, Integer j) |
| access to one element. | |
| Real const & | elt (Integer i, Integer j) const |
| access to one element const. | |
| Array2D | get2D (Range const &I, Range const &J) const |
| access to a sub-array. | |
| Vector | col (Integer j) const |
| access to a column. | |
| Vector | col (Range const &I, Integer j) const |
| access to a sub-col. | |
| Point | row (Integer const &i) const |
| access to a row. | |
| Point | row (Integer i, Range const &J) const |
| access to a sub-row. | |
| Range | compRangeVe (Integer const &icol) const |
| pseudo virtual method required by IArray2D. | |
| void | swapRows (Integer const &pos1, Integer pos2) |
| Swapping the pos1 row and the pos2 row. | |
| Array2D & | operator= (const Array2D &T) |
| operator = : overwrite the Array2D with T. | |
| Array2D & | operator= (Real const &v) |
| operator= : set the container to a constant value. | |
| Array2D & | operator+= (Real const &v) |
| operator += : add to the container a constant value. | |
| Array2D & | operator-= (Real const &v) |
| operator -= : Subtract to the container a constant value. | |
| Array2D & | operator*= (Real const &v) |
| operator *= : multiply to the container a constant value. | |
| Array2D & | operator/= (Real const &v) |
| operator /= : divide to the container a constant value. | |
| template<class Exp > | |
| Array2D & | operator= (const Exp &rhs) |
| operator = overwriting a Array2D with An Expression. | |
| template<class Exp > | |
| Array2D & | operator+= (const Exp &rhs) |
| operator += Adding an Expression. | |
| template<class Exp > | |
| Array2D & | operator-= (const Exp &rhs) |
| operator -= decreasing an Expression. | |
| template<class Exp > | |
| Array2D & | operator/= (const Exp &rhs) |
| operator /= Dividing an Expression. | |
| template<class Exp > | |
| Array2D & | operator*= (const Exp &rhs) |
| operator *= Multiplying an Expression. | |
Specialization of the Array2D class for Real values.
The Matrix class (Array2D<Real> specialization) is a final class. It would not possible to derive this class and to use the method
as the curious recursive template paradigm would be break.
Definition at line 67 of file STK_Matrix.h.
| typedef IArray2D<Real, Array2D<Real> > STK::Array2D< Real >::_IArray2DType |
Type for the Interface base Class.
Definition at line 71 of file STK_Matrix.h.
Default constructor.
| I | range of the Rows |
| J | range of the Cols |
Definition at line 77 of file STK_Matrix.h.
References STK::IArray2D< TYPE, Array2D< TYPE > >::initializeCols().
: _IArray2DType(I, J) { // initialize vertically the container this->initializeCols(J); }
constructor with rbeg, rend, cbeg and cend specified, initialization with a constant.
| I | range of the Rows |
| J | range of the Cols |
| v | initial value of the container |
Definition at line 90 of file STK_Matrix.h.
References STK::IArrayBase< TYPE * >::data(), STK::Range::first(), STK::IArray2D< TYPE, Array2D< TYPE > >::initializeCols(), and STK::Range::last().
: _IArray2DType(I, J) { // initialize vertically the container this->initializeCols(J); // initialize with v for (Integer j=J.first(); j<=J.last(); j++) { Real* p(this->data(j)); for (Integer i=I.first(); i<=I.last(); i++) p[i]= v; } }
| STK::Array2D< Real >::Array2D | ( | const Array2D< Real > & | T, |
| bool | ref = false |
||
| ) | [inline] |
Copy constructor.
| T | the container to copy |
| ref | true if T is wrapped |
Definition at line 107 of file STK_Matrix.h.
References STK::IArrayBase< DATA >::data(), STK::IArrayBase< TYPE * >::data(), STK::IContainer2D::firstCol(), STK::IContainer2D::firstRow(), STK::IArray2D< TYPE, Array2D< TYPE > >::initializeCols(), STK::IContainer2D::lastCol(), STK::IContainer2D::lastRow(), pt(), and STK::IContainer2D::rangeHo().
| STK::Array2D< Real >::Array2D | ( | const Array2D< Real > & | T, |
| Range const & | I, | ||
| Range const & | J | ||
| ) | [inline] |
constructor by reference, ref_=1.
| T | the container to wrap |
| I | range of the Rows to wrap |
| J | range of the Cols to wrap |
Definition at line 129 of file STK_Matrix.h.
: _IArray2DType(T, I, J) { ;}
Wrapper constructor Contruct a reference container.
| q | pointer on the data |
| I | range of the Rows to wrap |
| J | range of the Cols to wrap |
Definition at line 138 of file STK_Matrix.h.
: _IArray2DType(q, I, J) { ;}
| virtual STK::Array2D< Real >::~Array2D | ( | ) | [inline, virtual] |
| Real& STK::Array2D< Real >::elt | ( | Integer | i, |
| Integer | j | ||
| ) | [inline] |
access to one element.
Definition at line 147 of file STK_Matrix.h.
References STK::IArrayBase< TYPE * >::data().
{ return this->data(j)[i];}
| Real const& STK::Array2D< Real >::elt | ( | Integer | i, |
| Integer | j | ||
| ) | const [inline] |
access to one element const.
Definition at line 151 of file STK_Matrix.h.
References STK::IArrayBase< TYPE * >::data().
{ return this->data(j)[i];}
| Array2D STK::Array2D< Real >::get2D | ( | Range const & | I, |
| Range const & | J | ||
| ) | const [inline] |
access to a sub-array.
Definition at line 155 of file STK_Matrix.h.
References STK::Array2D< TYPE >::Array2D().
{ return Array2D(*this, I, J);}
| Vector STK::Array2D< Real >::col | ( | Integer | j | ) | const [inline] |
access to a column.
Reimplemented from STK::ITContainer2D< Real, ArrayHo< Real >, Array1D< Real >, Array2D< Real > >.
Definition at line 159 of file STK_Matrix.h.
References STK::IArrayBase< TYPE * >::data(), and STK::IContainer2D::rangeVe().
| Vector STK::Array2D< Real >::col | ( | Range const & | I, |
| Integer | j | ||
| ) | const [inline] |
access to a sub-col.
Definition at line 163 of file STK_Matrix.h.
References STK::IArrayBase< TYPE * >::data().
| Point STK::Array2D< Real >::row | ( | Integer const & | i | ) | const [inline] |
access to a row.
| i | index of the row |
Reimplemented from STK::IArray2D< Real, Array2D< Real > >.
Definition at line 170 of file STK_Matrix.h.
References STK::IContainer2D::rangeHo().
| Point STK::Array2D< Real >::row | ( | Integer | i, |
| Range const & | J | ||
| ) | const [inline] |
| Range STK::Array2D< Real >::compRangeVe | ( | Integer const & | icol | ) | const [inline] |
pseudo virtual method required by IArray2D.
compute the range of the effectively stored elements in the col icol.
| icol | the index of the column to compute the range |
Definition at line 182 of file STK_Matrix.h.
References STK::IContainer2D::rangeVe().
{ return this->rangeVe();}
| void STK::Array2D< Real >::swapRows | ( | Integer const & | pos1, |
| Integer | pos2 | ||
| ) | [inline] |
Swapping the pos1 row and the pos2 row.
| pos1 | position of the first row |
| pos2 | position of the second row |
Definition at line 189 of file STK_Matrix.h.
References STK::IRecursiveTemplate< Array2D< TYPE > >::asLeaf(), STK::IArray2D< TYPE, Array2D< TYPE > >::elt(), STK::IContainer2D::firstCol(), STK::IContainer2D::firstRow(), STK::IContainer2D::lastCol(), and STK::IContainer2D::lastRow().
{
#ifdef STK_BOUNDS_CHECK
// check conditions
if (this->firstRow() > pos1)
{ throw std::out_of_range("Array2D::swapRows(pos1, pos2) "
"this->firstRow() > pos1");
}
if (this->lastRow() < pos1)
{ throw std::out_of_range("Array2D::swapRows(pos1, pos2) "
"this->lastRow() < pos1");
}
if (this->firstRow() > pos2)
{ throw std::out_of_range("Array2D::swapRows(pos1, pos2) "
"this->firstRow() > pos2");
}
if (this->lastRow() < pos2)
{ throw std::out_of_range("Array2D::swapRows(pos1, pos2) "
"this->lastRow() < pos2");
}
#endif
// swap
for (Integer j=this->firstCol(); j<=this->lastCol(); j++)
{
Real aux(this->asLeaf().elt(pos1, j));
this->asLeaf().elt(pos1, j) = this->asLeaf().elt(pos2, j);
this->asLeaf().elt(pos2, j) = aux;
}
}
| Array2D& STK::Array2D< Real >::operator= | ( | const Array2D< Real > & | T | ) | [inline] |
operator = : overwrite the Array2D 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.
| T | the container to copy |
Definition at line 225 of file STK_Matrix.h.
References STK::IArrayBase< DATA >::data(), STK::IArrayBase< TYPE * >::data(), STK::IContainer2D::firstCol(), STK::IContainer2D::firstRow(), STK::IContainer2D::lastCol(), STK::IContainer2D::lastRow(), pt(), STK::IContainer2D::rangeHo(), STK::IContainer2D::rangeVe(), STK::IContainer2D::resize(), STK::IContainer2D::sizeHo(), and STK::IContainer2D::sizeVe().
{
// Resize if necessary.
if ( (this->sizeVe() != T.sizeVe())
||(this->sizeHo() != T.sizeHo())
)
this->resize(T.rangeVe(), T.rangeHo());
// Copy without overlapping
if (T.firstRow()>=this->firstRow())
{
if (T.firstCol()>=this->firstCol())
{
for ( Integer jt=T.firstCol(), j=this->firstCol()
; jt<=T.lastCol()
; j++, jt++
)
{
Real *p =this->data(j), *pt =T.data(jt);
for ( Integer it=T.firstRow(), i=this->firstRow()
; it<=T.lastRow()
; 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), *pt =T.data(jt);
for ( Integer it=T.firstRow(), i=this->firstRow()
; it<=T.lastRow()
; i++, it++
)
p[i] = pt[it];
}
return *this;
}
// T.firstRow()<this->firstRow()
if (T.firstCol()>=this->firstCol())
{
for ( Integer jt=T.firstCol(), j=this->firstCol()
; jt<=T.lastCol()
; j++, jt++
)
{
Real *p =this->data(j), *pt =T.data(jt);
for ( Integer it=T.lastRow(), i=this->lastRow()
; it>=T.firstRow()
; 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), *pt =T.data(jt);
for ( Integer it=T.lastRow(), i=this->lastRow()
; it>=T.firstRow()
; i--, it--
)
p[i] = pt[it];
}
return *this;
}
| Array2D& STK::Array2D< Real >::operator= | ( | Real const & | v | ) | [inline] |
operator= : set the container to a constant value.
| v | the value to set |
Reimplemented in STK::MatrixSquare.
Definition at line 302 of file STK_Matrix.h.
References STK::IArrayBase< TYPE * >::data(), STK::IContainer2D::firstCol(), STK::IContainer2D::firstRow(), STK::IContainer2D::lastCol(), and STK::IContainer2D::lastRow().
| Array2D& STK::Array2D< Real >::operator+= | ( | Real const & | v | ) | [inline] |
operator += : add to the container a constant value.
| v | the value to set |
Definition at line 315 of file STK_Matrix.h.
References STK::IArrayBase< TYPE * >::data(), STK::IContainer2D::firstCol(), STK::IContainer2D::firstRow(), STK::IContainer2D::lastCol(), and STK::IContainer2D::lastRow().
| Array2D& STK::Array2D< Real >::operator-= | ( | Real const & | v | ) | [inline] |
operator -= : Subtract to the container a constant value.
| v | the value to set |
Definition at line 328 of file STK_Matrix.h.
References STK::IArrayBase< TYPE * >::data(), STK::IContainer2D::firstCol(), STK::IContainer2D::firstRow(), STK::IContainer2D::lastCol(), and STK::IContainer2D::lastRow().
| Array2D& STK::Array2D< Real >::operator*= | ( | Real const & | v | ) | [inline] |
operator *= : multiply to the container a constant value.
| v | the value to set |
Definition at line 341 of file STK_Matrix.h.
References STK::IArrayBase< TYPE * >::data(), STK::IContainer2D::firstCol(), STK::IContainer2D::firstRow(), STK::IContainer2D::lastCol(), and STK::IContainer2D::lastRow().
| Array2D& STK::Array2D< Real >::operator/= | ( | Real const & | v | ) | [inline] |
operator /= : divide to the container a constant value.
| v | the value to set |
Definition at line 354 of file STK_Matrix.h.
References STK::IArrayBase< TYPE * >::data(), STK::IContainer2D::firstCol(), STK::IContainer2D::firstRow(), STK::IContainer2D::lastCol(), and STK::IContainer2D::lastRow().
| Array2D& STK::Array2D< Real >::operator= | ( | const Exp & | rhs | ) | [inline] |
operator = overwriting a Array2D with An Expression.
| rhs | the right hand side expression |
Definition at line 368 of file STK_Matrix.h.
References STK::IArray2D< TYPE, Array2D< TYPE > >::elt(), STK::IContainer2D::firstCol(), STK::IContainer2D::firstRow(), STK::IContainer2D::lastCol(), and STK::IContainer2D::lastRow().
| Array2D& STK::Array2D< Real >::operator+= | ( | const Exp & | rhs | ) | [inline] |
operator += Adding an Expression.
| rhs | the right hand side expression |
Definition at line 382 of file STK_Matrix.h.
References STK::IArray2D< TYPE, Array2D< TYPE > >::col(), STK::IContainer2D::firstCol(), STK::IContainer2D::lastCol(), and STK::IContainer2D::rangeVe().
| Array2D& STK::Array2D< Real >::operator-= | ( | const Exp & | rhs | ) | [inline] |
operator -= decreasing an Expression.
| rhs | the right hand side expression |
Definition at line 393 of file STK_Matrix.h.
References STK::IArray2D< TYPE, Array2D< TYPE > >::col(), STK::IContainer2D::firstCol(), STK::IContainer2D::lastCol(), and STK::IContainer2D::rangeVe().
| Array2D& STK::Array2D< Real >::operator/= | ( | const Exp & | rhs | ) | [inline] |
operator /= Dividing an Expression.
| rhs | the right hand side expression |
Definition at line 404 of file STK_Matrix.h.
References STK::IArray2D< TYPE, Array2D< TYPE > >::col(), STK::IContainer2D::firstCol(), STK::IContainer2D::lastCol(), and STK::IContainer2D::rangeVe().
| Array2D& STK::Array2D< Real >::operator*= | ( | const Exp & | rhs | ) | [inline] |
operator *= Multiplying an Expression.
| rhs | the right hand side expression |
Definition at line 415 of file STK_Matrix.h.
References STK::IArray2D< TYPE, Array2D< TYPE > >::col(), STK::IContainer2D::firstCol(), STK::IContainer2D::lastCol(), and STK::IContainer2D::rangeVe().