STK++ 0.9.13
STK::TRange< Size_ > Class Template Reference

Index sub-vector region with fixed size. More...

#include <STK_Range.h>

Inheritance diagram for STK::TRange< Size_ >:
Inheritance graph

Public Types

typedef RangeBase< TRange< Size_ > > Base
 

Public Member Functions

 TRange (int size=Size_)
 Default constructor.
 
 TRange (int first, int)
 Full constructor.
 
 TRange (int first, int, bool)
 Complete constructor.
 
 TRange (TRange const &I)
 copy constructor
 
template<int OtherSize_>
 TRange (TRange< OtherSize_ > const &I)
 copy constructor
 
 ~TRange ()
 destructor.
 
int end () const
 get the ending index of the TRange.
 
int size () const
 get the size of the TRange (the number of elements).
 
bool empty () const
 check if the range is empty or not.
 
int lastIdx () const
 get the last index of the TRange.
 
TRangeshift (int begin)
 Shift the TRange giving the first element.
 
TRangeinc (int inc=1)
 create the TRange [begin_+inc, end_+inc_].
 
TRangedec (int dec=1)
 create the TRange [begin_-dec, end_-dec]
 
TRangeincFirst (int inc=1)
 create the TRange [begin_+inc, end_].
 
TRangedecFirst (int dec=1)
 create the TRange [begin_-dec, end_]
 
TRangeincEnd (int inc=1)
 create the TRange [begin_, end_+inc)
 
TRangedecEnd (int dec=1)
 create the TRange [begin_, end_-dec)
 
TRangeincLast (int inc=1)
 create the TRange [begin_, end_+inc)
 
TRangedecLast (int dec=1)
 create the TRange [begin_, end_-dec)
 
- Public Member Functions inherited from STK::RangeBase< TRange< Size_ > >
 ~RangeBase ()
 destructor.
 
int begin () const
 get the first index of the TRange.
 
bool isIn (TRange< OtherSize_ > const &I) const
 check if this TRange in include in an other TRange
 
bool isContaining (TRange< OtherSize_ > const &I) const
 check if the TRange I is include in the this TRange
 
bool isContaining (int i) const
 Return true if i is in this TRange.
 
TRange< Size_ > & operator+= (int i)
 shift range a:b becomes (a+i):(b+i)
 
TRange< Size_ > & operator-= (int i)
 shift range a:b becomes (a+i):(b+i)
 
bool operator== (TRange< OtherSize_ > const &I) const
 compare this range with range I
 
bool operator!= (TRange< OtherSize_ > const &I) const
 compare this range with range I
 
- Public Member Functions inherited from STK::IRecursiveTemplate< Derived >
Derived & asDerived ()
 static cast : return a reference of this with a cast to the derived class.
 
Derived constasDerived () const
 static cast : return a const reference of this with a cast to the derived class.
 
Derived * asPtrDerived ()
 static cast : return a ptr on a Derived of this with a cast to the derived class.
 
Derived constasPtrDerived () const
 static cast : return a ptr on a constant Derived of this with a cast to the derived class.
 
Derived * clone () const
 create a leaf using the copy constructor of the Derived class.
 
Derived * clone (bool isRef) const
 create a leaf using the copy constructor of the Derived class and a flag determining if the clone is a reference or not.
 

Additional Inherited Members

- Protected Member Functions inherited from STK::RangeBase< TRange< Size_ > >
 RangeBase ()
 Default constructor.
 
 RangeBase (int begin)
 constructor.
 
 RangeBase (RangeBase const &I)
 Copy constructor.
 
 RangeBase (RangeBase< OtherDerived > const &I)
 Copy constructor.
 
- Protected Member Functions inherited from STK::IRecursiveTemplate< Derived >
 IRecursiveTemplate ()
 constructor.
 
 ~IRecursiveTemplate ()
 destructor.
 
- Protected Attributes inherited from STK::RangeBase< TRange< Size_ > >
int begin_
 First index.
 

Detailed Description

template<int Size_>
class STK::TRange< Size_ >

Index sub-vector region with fixed size.

A TRange is an ordered pair [first,end) denoting a sub-vector region, similar to a Fortran 90 or Matlab colon notation. For example:

Vector A(10), B(Range(0,20));
Range I(2,4, false);
A(I) = B(Range(0,2, false));
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Index sub-vector region: Specialization when the size is unknown.
Definition STK_Range.h:265
TRange< UnknownSize > Range
Definition STK_Range.h:59

overwrites the elements (2, 3, 4) of A by the elements (0, 1, 2) of B. There is no stride argument, only contiguous regions are allowed.

Definition at line 160 of file STK_Range.h.

Member Typedef Documentation

◆ Base

template<int Size_>
typedef RangeBase< TRange<Size_> > STK::TRange< Size_ >::Base

Definition at line 163 of file STK_Range.h.

Constructor & Destructor Documentation

◆ TRange() [1/5]

template<int Size_>
STK::TRange< Size_ >::TRange ( int  size = Size_)
inline

Default constructor.

Give the size of the sub-region.

Parameters
sizesize of the sub-region (size is not used in fixed size range)

Definition at line 169 of file STK_Range.h.

169: Base() {}
RangeBase< TRange< Size_ > > Base
Definition STK_Range.h:163

◆ TRange() [2/5]

template<int Size_>
STK::TRange< Size_ >::TRange ( int  first,
int   
)
inline

Full constructor.

Give the beginning and the size of the sub-region.

Parameters
firstbeginning of the sub-region

Definition at line 173 of file STK_Range.h.

173: Base(first) {}

◆ TRange() [3/5]

template<int Size_>
STK::TRange< Size_ >::TRange ( int  first,
int  ,
bool   
)
inline

Complete constructor.

Give the beginning and the last indexes of the sub-region.

Parameters
firstfirst index of the sub-region

Definition at line 177 of file STK_Range.h.

177: Base(first) {}

◆ TRange() [4/5]

template<int Size_>
STK::TRange< Size_ >::TRange ( TRange< Size_ > const I)
inline

copy constructor

Parameters
IRange to copy

Definition at line 181 of file STK_Range.h.

181: Base(I) {}

◆ TRange() [5/5]

template<int Size_>
template<int OtherSize_>
STK::TRange< Size_ >::TRange ( TRange< OtherSize_ > const I)
inline

copy constructor

Parameters
IRange to copy

Definition at line 186 of file STK_Range.h.

186: Base(I) {}

◆ ~TRange()

template<int Size_>
STK::TRange< Size_ >::~TRange ( )
inline

destructor.

Definition at line 188 of file STK_Range.h.

188{}

Member Function Documentation

◆ dec()

template<int Size_>
TRange & STK::TRange< Size_ >::dec ( int  dec = 1)
inline

create the TRange [begin_-dec, end_-dec]

Parameters
decthe decrement to apply

Definition at line 218 of file STK_Range.h.

218{ begin_ -=dec; return *this;}
TRange & dec(int dec=1)
create the TRange [begin_-dec, end_-dec]
Definition STK_Range.h:218

References STK::RangeBase< TRange< Size_ > >::begin_, and STK::TRange< Size_ >::dec().

Referenced by STK::TRange< Size_ >::dec(), STK::TRange< UnknownSize >::decEnd(), STK::TRange< Size_ >::decFirst(), STK::TRange< UnknownSize >::decFirst(), and STK::TRange< UnknownSize >::decLast().

◆ decEnd()

template<int Size_>
TRange & STK::TRange< Size_ >::decEnd ( int  dec = 1)
inline

create the TRange [begin_, end_-dec)

Parameters
decthe decrement to apply

Definition at line 236 of file STK_Range.h.

236{ return *this;}

◆ decFirst()

template<int Size_>
TRange & STK::TRange< Size_ >::decFirst ( int  dec = 1)
inline

create the TRange [begin_-dec, end_]

Parameters
decthe decrement to apply

Definition at line 227 of file STK_Range.h.

227{ begin_ -=dec; return *this;}

References STK::RangeBase< TRange< Size_ > >::begin_, and STK::TRange< Size_ >::dec().

Referenced by STK::IContainer2D< SizeRows_, SizeCols_ >::decBeginCols(), and STK::IContainer2D< SizeRows_, SizeCols_ >::decBeginRows().

◆ decLast()

template<int Size_>
TRange & STK::TRange< Size_ >::decLast ( int  dec = 1)
inline

◆ empty()

template<int Size_>
bool STK::TRange< Size_ >::empty ( ) const
inline

check if the range is empty or not.

Returns
true if size <=0, false otherwise

Definition at line 200 of file STK_Range.h.

200{ return Size_<=0;};

Referenced by STK::IContainer2D< SizeRows_, SizeCols_ >::empty().

◆ end()

◆ inc()

◆ incEnd()

template<int Size_>
TRange & STK::TRange< Size_ >::incEnd ( int  inc = 1)
inline

create the TRange [begin_, end_+inc)

Parameters
incthe increment to apply

Definition at line 232 of file STK_Range.h.

232{ return *this;}

◆ incFirst()

template<int Size_>
TRange & STK::TRange< Size_ >::incFirst ( int  inc = 1)
inline

create the TRange [begin_+inc, end_].

Parameters
incthe increment to apply

Definition at line 223 of file STK_Range.h.

223{ begin_ +=inc; return *this;}

References STK::RangeBase< TRange< Size_ > >::begin_, and STK::TRange< Size_ >::inc().

Referenced by STK::IContainer2D< SizeRows_, SizeCols_ >::incBeginCols(), and STK::IContainer2D< SizeRows_, SizeCols_ >::incBeginRows().

◆ incLast()

◆ lastIdx()

template<int Size_>
int STK::TRange< Size_ >::lastIdx ( ) const
inline

get the last index of the TRange.

Returns
the last index of the range

Definition at line 206 of file STK_Range.h.

206{ return begin_ + Size_ -1;};

References STK::RangeBase< TRange< Size_ > >::begin_.

Referenced by STK::IContainer2D< SizeRows_, SizeCols_ >::lastIdxCols(), STK::IContainer2D< SizeRows_, SizeCols_ >::lastIdxRows(), and STK::IArray2D< Derived >::merge().

◆ shift()

template<int Size_>
TRange & STK::TRange< Size_ >::shift ( int  begin)
inline

Shift the TRange giving the first element.

Parameters
beginnew value of the first element.

Definition at line 210 of file STK_Range.h.

210{ begin_= begin; return *this;}
int begin() const
get the first index of the TRange.
Definition STK_Range.h:93

References STK::RangeBase< TRange< Size_ > >::begin(), and STK::RangeBase< TRange< Size_ > >::begin_.

Referenced by STK::IContainer2D< SizeRows_, SizeCols_ >::shift(), STK::IContainer2D< SizeRows_, SizeCols_ >::shiftCols(), and STK::IContainer2D< SizeRows_, SizeCols_ >::shiftRows().

◆ size()

template<int Size_>
int STK::TRange< Size_ >::size ( ) const
inline

get the size of the TRange (the number of elements).

Returns
the size of the range

Definition at line 196 of file STK_Range.h.

196{ return Size_;};

Referenced by STK::IContainer2D< SizeRows_, SizeCols_ >::sizeCols(), STK::ITContainerBase< Derived >::sizeCols(), STK::IContainer2D< SizeRows_, SizeCols_ >::sizeRows(), and STK::ITContainerBase< Derived >::sizeRows().


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