|
STK++ 1.0
|
Index sub-vector region. More...
#include <STK_Range.h>

Public Member Functions | |
| Range (Integer const &last=0) | |
| Default constructor. | |
| Range (Integer const &first, Integer const &last) | |
| Complete constructor. | |
| Range (Range const &I) | |
| Copy constructor. | |
| ~Range () | |
| destructor. | |
| Integer const & | first () const |
| get the first index of the Range | |
| Integer const & | last () const |
| get the last index of the Range | |
| Integer const & | size () const |
| get the size of the Range (the number of elements) | |
| bool | empty () const |
| check if the range is empty or not | |
| bool | isIn (Range const &I) const |
| check if this Range in include in an other Range | |
| bool | isContaining (Range const &I) const |
| check if the Range I is include in the this Range | |
| bool | isContaining (Integer const &i) const |
| Return true if i is in this Range. | |
| bool | operator== (Range const &I) const |
compare this range with range I | |
| bool | operator!= (Range const &I) const |
compare this range with range I | |
| Range & | set (Integer const &first=1, Integer const &last=0) |
| Set dimensions of the Index. | |
| Range & | shift (Integer const &first=1) |
| create the Range [first, first+size_]. | |
| Range & | inc (Integer const &inc=1) |
| create the Range [first_+inc, last_+inc_]. | |
| Range & | incFirst (Integer const &inc=1) |
| create the Range [first_+inc, last_]. | |
| Range & | incLast (Integer const &inc=1) |
| create the Range [first_, last_+inc]. | |
| Range & | dec (Integer const &dec=1) |
| create the Range [first_-dec, last_-dec]. | |
| Range & | decFirst (Integer const &dec=1) |
| create the Range [first_-dec, last_]. | |
| Range & | decLast (Integer const &dec=1) |
| create the Range [first_, last_-dec]. | |
| Range & | sup (Range const &I) |
| compute sup(this,J) | |
| Range & | inf (Range const &I) |
| compute inf(this,J) | |
| Range & | operator+= (Integer const &inc) |
same as Range::inc() | |
| Range & | operator-= (Integer const &dec) |
same as Range::dec() | |
| Range | plus (Integer const &inc=1) |
| create the Range [first_+inc, last_+inc_]. | |
| Range | minus (Integer const &dec=1) |
| create the Range [first_-dec, last_-dec]. | |
Static Public Member Functions | |
| static Range | sup (Range const &I, Range const &J) |
| compute sup(I,J) | |
| static Range | inf (Range const &I, Range const &J) |
| compute inf(I,J)I | |
Private Attributes | |
| Integer | first_ |
| First index. | |
| Integer | last_ |
| Last index. | |
| Integer | size_ |
| Theoretic Dimension size_ = last_- first_ +1. | |
Friends | |
| ostream & | operator<< (ostream &s, Range const &I) |
| Write a Range in the form first:last (MATLAB-like form) in an output stream. | |
| istream & | operator>> (istream &s, Range &I) |
| Read a Range in the form first:last (MATLAB-like form) from an input stream. | |
Index sub-vector region.
An Range is an ordered pair [first,last] denoting a sub-vector region, similar to a Fortran 90 or Matlab colon notation. For example :
overwrite the elements 2, 3 and 4 of A by the elements 0, 1 and 2 of B. There is no stride argument, only contiguous regions are allowed.
Definition at line 62 of file STK_Range.h.
| STK::Range::Range | ( | Integer const & | last = 0 | ) |
Default constructor.
The Default constructor Assume the beginning of the sub-region is 1.
The first index is 1.
| last | the last index of the range |
| last | the end of the sub-region. |
Definition at line 48 of file STK_Range.cpp.
Complete constructor.
Complete constructor We have to give the beginning and the end of the sub-region.
| first | is the beginning of the sub-region |
| last | is the end of the sub-region. |
| first | the beginning of the sub-region |
| last | the end of the sub-region. |
Definition at line 59 of file STK_Range.cpp.
| STK::Range::Range | ( | Range const & | I | ) |
| STK::Range::~Range | ( | ) |
| Integer const& STK::Range::first | ( | ) | const [inline] |
get the first index of the Range
Definition at line 92 of file STK_Range.h.
References first_.
Referenced by STK::Array2D< Real >::Array2D(), STK::Array2D< Integer >::Array2D(), STK::ITContainer2D< Integer, Array2D< Integer > >::at(), STK::ITContainer2D< Integer, Array2D< Integer > >::atCol(), STK::ITContainer2D< Integer, Array2D< Integer > >::atRow(), STK::CArray2D< TYPE >::CArray2D(), STK::Stat::Bivariate< Real, Real, TContainer1D >::compCovariance(), STK::CArray2D< TYPE >::compFirstData(), STK::LocalVariance::computeAxis(), STK::Stat::Bivariate< Real, Real, TContainer1D >::compWeightedCovariance(), STK::Stat::covariance(), STK::Stat::covarianceWithFixedMean(), STK::Array1D< Real >::elt(), STK::Variable< String >::elt(), STK::List1D< IVariable * >::elt(), STK::Array1D< Variable< String > >::elt(), STK::ITArray2D< Integer, Array2D< Integer > >::eraseRowsToCol(), STK::ITContainer1D< TYPE, List1D< TYPE > >::first(), STK::IContainer2D::firstCol(), STK::AllocatorBase< TYPE * >::firstData(), STK::IContainer2D::firstRow(), STK::ITArray2D< Integer, Array2D< Integer > >::freeCols(), STK::ArrayHo< Real >::freeElts(), STK::ArrayHo< TYPE >::freeElts(), STK::IArray1DBase< Range, Range, Array1D< Range > >::IArray1DBase(), STK::IArray1DBase< Range, Range, Array1D< Range > >::init1D(), STK::ArrayHo< Real >::initElts(), STK::ArrayHo< TYPE >::initElts(), STK::ITArray2D< Integer, Array2D< Integer > >::initializeCol(), STK::ITArray2D< Integer, Array2D< Integer > >::initializeCols(), STK::List1D< IVariable * >::insert(), STK::IArray1DBase< Range, Range, Array1D< Range > >::insert(), STK::ITArray2D< Integer, Array2D< Integer > >::insertRowsToCol(), STK::ITArray2DBase< TYPE, TYPE *, TArray2D >::ITArray2DBase(), STK::ITArray2DBase< TYPE, TYPE *, TArray2D >::mallocHo(), STK::MatrixLowerTriangular::MatrixLowerTriangular(), STK::MatrixUpperTriangular::MatrixUpperTriangular(), operator!=(), STK::operator+(), STK::operator-(), operator==(), STK::ITArray2D< Integer, Array2D< Integer > >::pushBackRowsToCol(), STK::ITArray2DBase< TYPE, TYPE *, TArray2D >::reallocHo(), STK::RecursiveArray2D< TYPE, Container2D >::RecursiveArray2D(), STK::IContainer2D::resize(), STK::IContainer1D::resize(), STK::ITArray2D< Integer, Array2D< Integer > >::resizeCol(), set(), and STK::ITArray2D< Integer, Array2D< Integer > >::update().
{ return first_;};
| Integer const& STK::Range::last | ( | ) | const [inline] |
get the last index of the Range
Definition at line 96 of file STK_Range.h.
References last_.
Referenced by STK::Array2D< Real >::Array2D(), STK::Array2D< Integer >::Array2D(), STK::ITContainer2D< Integer, Array2D< Integer > >::at(), STK::ITContainer2D< Integer, Array2D< Integer > >::atCol(), STK::ITContainer2D< Integer, Array2D< Integer > >::atRow(), STK::CArray2D< TYPE >::CArray2D(), STK::Stat::Bivariate< Real, Real, TContainer1D >::compCovariance(), STK::LocalVariance::computeAxis(), STK::Stat::Bivariate< Real, Real, TContainer1D >::compWeightedCovariance(), STK::Stat::covariance(), STK::Stat::covarianceWithFixedMean(), STK::Array1D< Real >::elt(), STK::Variable< String >::elt(), STK::List1D< IVariable * >::elt(), STK::Array1D< Variable< String > >::elt(), STK::ITArray2D< Integer, Array2D< Integer > >::eraseRowsToCol(), STK::ITArray2D< Integer, Array2D< Integer > >::freeCols(), STK::ArrayHo< Real >::freeElts(), STK::ArrayHo< TYPE >::freeElts(), STK::IArray1DBase< Range, Range, Array1D< Range > >::IArray1DBase(), STK::ArrayHo< Real >::initElts(), STK::ArrayHo< TYPE >::initElts(), STK::ITArray2D< Integer, Array2D< Integer > >::initializeCols(), STK::List1D< IVariable * >::insert(), STK::IArray1DBase< Range, Range, Array1D< Range > >::insert(), STK::ITArray2D< Integer, Array2D< Integer > >::insertRowsToCol(), STK::ITArray2DBase< TYPE, TYPE *, TArray2D >::ITArray2DBase(), STK::ITContainer1D< TYPE, List1D< TYPE > >::last(), STK::IContainer2D::lastCol(), STK::AllocatorBase< TYPE * >::lastData(), STK::IContainer2D::lastRow(), STK::MatrixLowerTriangular::MatrixLowerTriangular(), STK::MatrixUpperTriangular::MatrixUpperTriangular(), operator!=(), STK::operator+(), STK::operator-(), operator==(), STK::ITArray2DBase< TYPE, TYPE *, TArray2D >::pushBackByTransfer(), STK::ITArray2D< Integer, Array2D< Integer > >::pushBackRows(), STK::ITArray2D< Integer, Array2D< Integer > >::pushBackRowsToCol(), STK::RecursiveArray2D< TYPE, Container2D >::RecursiveArray2D(), STK::IContainer2D::resize(), STK::IContainer1D::resize(), set(), and STK::ITArray2D< Integer, Array2D< Integer > >::update().
{ return last_;};
| Integer const& STK::Range::size | ( | ) | const [inline] |
get the size of the Range (the number of elements)
Definition at line 100 of file STK_Range.h.
References size_.
Referenced by STK::Stat::Bivariate< Real, Real, TContainer1D >::compCovariance(), STK::CArray2D< TYPE >::compFirstData(), STK::Stat::covariance(), STK::Stat::covarianceWithFixedMean(), STK::IArray1DBase< Range, Range, Array1D< Range > >::init1D(), STK::CArray2D< TYPE >::initialize(), STK::ITArray2D< Integer, Array2D< Integer > >::initializeCol(), STK::List1D< IVariable * >::insert(), STK::IArray1DBase< Range, Range, Array1D< Range > >::insert(), STK::ITArray2D< Integer, Array2D< Integer > >::insertCols(), STK::ITArray2DBase< TYPE, TYPE *, TArray2D >::mallocHo(), STK::ITArray2D< Integer, Array2D< Integer > >::pushBackRows(), STK::ITArray2D< Integer, Array2D< Integer > >::pushBackRowsToCol(), STK::ITArray2DBase< TYPE, TYPE *, TArray2D >::reallocHo(), STK::ITArray2D< Integer, Array2D< Integer > >::resizeCol(), STK::ITContainer1D< TYPE, List1D< TYPE > >::size(), STK::AllocatorBase< TYPE * >::sizeData(), STK::IContainer2D::sizeHo(), and STK::IContainer2D::sizeVe().
{ return size_;};
| bool STK::Range::empty | ( | ) | const [inline] |
check if the range is empty or not
true if size <=0, false otherwise Definition at line 104 of file STK_Range.h.
References size_.
Referenced by STK::Stat::covariance(), STK::Stat::covarianceWithFixedMean(), STK::IContainer2D::empty(), and STK::IContainer1D::empty().
{ return size_<=0;};
| bool STK::Range::isIn | ( | Range const & | I | ) | const [inline] |
check if this Range in include in an other Range
| I | the index to compare |
true if this is include in I, false otherwise Definition at line 109 of file STK_Range.h.
Referenced by STK::Stat::center(), STK::Stat::covariance(), STK::Stat::covarianceWithFixedMean(), STK::weightedDist(), STK::weightedDot(), STK::weightedNormInf(), STK::weightedNormTwo(), STK::weightedNormTwo2(), and STK::weightedSum().
| bool STK::Range::isContaining | ( | Range const & | I | ) | const [inline] |
| bool STK::Range::isContaining | ( | Integer const & | i | ) | const [inline] |
| bool STK::Range::operator== | ( | Range const & | I | ) | const [inline] |
| bool STK::Range::operator!= | ( | Range const & | I | ) | const [inline] |
create the Range [first, first+size_].
Shift the Range giving the first element : the size is not modified.
| first | new value of the first element |
Definition at line 94 of file STK_Range.cpp.
Referenced by STK::IContainer2D::setFirstHo(), and STK::IContainer2D::setFirstVe().

create the Range [first_+inc, last_+inc_].
Increase first_ and last_.
| inc | the increment to apply |
Definition at line 102 of file STK_Range.cpp.
Referenced by STK::AllocatorBase< TYPE * >::decPtrData(), incFirst(), incLast(), STK::ITContainer1D< TYPE, List1D< TYPE > >::incRange(), STK::IContainer2D::incRangeHo(), STK::IContainer2D::incRangeVe(), operator+=(), plus(), and shift().
create the Range [first_+inc, last_].
Increase first_.
| inc | the increment to apply |
Definition at line 111 of file STK_Range.cpp.
References first_, inc(), and size_.
Referenced by STK::Svd::bidiag(), STK::ITContainer1D< TYPE, List1D< TYPE > >::incFirst(), STK::IContainer2D::incFirstHo(), STK::IContainer2D::incFirstVe(), and STK::EigenvaluesSymmetric::tridiagonalize().

create the Range [first_, last_+inc].
Increase last_.
| inc | the increment to apply |
Definition at line 120 of file STK_Range.cpp.
References inc(), last_, and size_.
Referenced by STK::ITContainer1D< TYPE, List1D< TYPE > >::incLast(), STK::IContainer2D::incLastHo(), STK::IContainer2D::incLastVe(), STK::ITArray2D< Integer, Array2D< Integer > >::insertCols(), STK::RecursiveArray1D< Integer, Array1D< Integer > >::insertElt(), STK::ArrayHo< Real >::insertElt(), STK::ArrayHo< TYPE >::insertElt(), and STK::ITArray2DBase< TYPE, TYPE *, TArray2D >::pushBackByTransfer().

create the Range [first_-dec, last_-dec].
Decrease first_ and last_.
| dec | the decrement to apply |
Definition at line 130 of file STK_Range.cpp.
Referenced by decFirst(), decLast(), STK::IContainer2D::decRangeHo(), STK::IContainer2D::decRangeVe(), STK::AllocatorBase< TYPE * >::incPtrData(), minus(), and operator-=().
create the Range [first_-dec, last_].
Decrease first_.
| dec | the decrement to apply |
Definition at line 139 of file STK_Range.cpp.
References dec(), first_, and size_.
Referenced by STK::Svd::compV(), STK::ITContainer1D< TYPE, List1D< TYPE > >::decFirst(), STK::IContainer2D::decFirstHo(), and STK::IContainer2D::decFirstVe().

create the Range [first_, last_-dec].
Decrease last_.
| dec | the decrement to apply |
Definition at line 148 of file STK_Range.cpp.
References dec(), last_, and size_.
Referenced by STK::ITContainer1D< TYPE, List1D< TYPE > >::decLast(), STK::IContainer2D::decLastHo(), STK::IContainer2D::decLastVe(), and STK::ITArray2D< Integer, Array2D< Integer > >::eraseRowsToCol().

compute sup(this,J)
Take the lowest value of first_ and I.first_ for first_ and the largest value of last_ and I.last_ for last_.
| I | the index to apply |
Definition at line 159 of file STK_Range.cpp.
References first_, last_, STK::max(), STK::min(), and size_.
{
first_ = min(first_, I.first_);
last_ = max(last_, I.last_);
size_ = last_ - first_ +1;
return *this;
}

compute inf(this,J)
Take the largest value of first_ and I.first_ for first_ and the lowest value of last_ and I.last_ for last_.
| I | the index to apply |
Definition at line 171 of file STK_Range.cpp.
References first_, last_, STK::max(), STK::min(), and size_.
Referenced by STK::MatrixUpperTriangular::col(), STK::MatrixLowerTriangular::col(), STK::Stat::Bivariate< Real, Real, TContainer1D >::compCovariance(), STK::Stat::Bivariate< Real, Real, TContainer1D >::compWeightedCovariance(), STK::Stat::covariance(), STK::Stat::covarianceWithFixedMean(), STK::ITArray2DBase< TYPE, TYPE *, TArray2D >::ITArray2DBase(), STK::MatrixUpperTriangular::row(), and STK::MatrixLowerTriangular::row().
{
first_ = max(first_, I.first_);
last_ = min(last_, I.last_);
size_ = last_ - first_ +1;
return *this;
}

same as Range::inc()
Increase first_ and last_.
| inc | the increment to apply |
Definition at line 213 of file STK_Range.cpp.
References first_, inc(), and last_.

same as Range::dec()
Decrease first_ and last_.
| dec | the decrement to apply |
Definition at line 219 of file STK_Range.cpp.
References dec(), first_, and last_.

create the Range [first_+inc, last_+inc_].
Definition at line 199 of file STK_Range.cpp.
References inc().
{
return *this+inc;
}

create the Range [first_-dec, last_-dec].
Definition at line 204 of file STK_Range.cpp.
References dec().
{
return *this-dec;
;
}

compute sup(I,J)
Take the lowest value of I.first_ and J.first_ for first_ and the largest value of I.last_ and J.last_ for last_.
| I | first the index to apply |
| J | second the index to apply |
Definition at line 183 of file STK_Range.cpp.
References first_, last_, STK::max(), STK::min(), and Range().

compute inf(I,J)I
Take the largest value of I.first_ and J.first_ for first_ and the lowest value of I.last_ and J.last_ for last_.
| I | first the index to apply |
| J | second the index to apply |
Definition at line 193 of file STK_Range.cpp.
References first_, last_, STK::max(), STK::min(), and Range().

Write a Range in the form first:last (MATLAB-like form) in an output stream.
| s | output stream |
| I | the Range to write |
Definition at line 226 of file STK_Range.cpp.
{
s << I.first_ << _T(":") << I.last_;
return s;
}
Read a Range in the form first:last (MATLAB-like form) from an input stream.
The input stream can also be a number (say n). In this case the range will be 1:n. If the range cannot be read the method return the default range 1:0. FIXME? should be NA value, but NA value is not defined for Range.
| s | the input stream |
| I | the range to set |
Definition at line 240 of file STK_Range.cpp.
{
String num;
s >> std::skipws;
// get first number
std::getline(s, num, _T(':'));
// check if the istream is exhausted
if (s.eof())
{
I.first_ = 1;
if (!stringToType(I.last_, num)) I.last_ =0;
return s;
}
// otherwise we encounter a ":", thus skip the current char
if (!stringToType(I.first_, num)) I.first_ =1;
s.peek();
if ((s >> I.last_).fail())
{
I.first_ =1; I.last_ =0;
}
return s;
}
Integer STK::Range::first_ [private] |
First index.
Definition at line 65 of file STK_Range.h.
Referenced by dec(), decFirst(), first(), inc(), incFirst(), inf(), isContaining(), isIn(), operator!=(), operator+=(), operator-=(), STK::operator<<(), operator==(), STK::operator>>(), set(), shift(), and sup().
Integer STK::Range::last_ [private] |
Last index.
Definition at line 66 of file STK_Range.h.
Referenced by dec(), decLast(), inc(), incLast(), inf(), isContaining(), isIn(), last(), operator!=(), operator+=(), operator-=(), STK::operator<<(), operator==(), STK::operator>>(), set(), and sup().
Integer STK::Range::size_ [private] |
Theoretic Dimension size_ = last_- first_ +1.
Definition at line 67 of file STK_Range.h.
Referenced by decFirst(), decLast(), empty(), incFirst(), incLast(), inf(), set(), size(), and sup().