45#if defined(STKBASEARRAYS)
53#define _R(first,last) Range(first, last, 0)
58template<
int Size_>
class TRange;
67template<
class Derived>
84 template<
class OtherDerived>
99 template<
int OtherSize_>
101 {
return ((this->
asDerived().
begin() >= I.begin()) && (
this->asDerived().end() <=
I.end()));}
106 template<
int OtherSize_>
108 {
return ((
begin_<=
I.begin())&&(
this->asDerived().end()>=
I.end()));}
130 template<
int OtherSize_>
132 {
return ((
begin_ ==
I.begin()) && (
this->asDerived().end() ==
I.end()));}
137 template<
int OtherSize_>
139 {
return ((
begin_ !=
I.begin()) || (
this->asDerived().end() !=
I.end()));}
185 template<
int OtherSize_>
292 template<
int OtherSize_>
303 inline int size()
const {
return size_;}
307 inline bool empty()
const {
return size_<=0;}
359 template<
int OtherSize_>
370 template<
int OtherSize_>
402 {
return TRange<Size_>(std::numeric_limits<int>::min(), std::numeric_limits<int>::min(), 0);}
409 {
return (x.begin() == std::numeric_limits<int>::min());}
434 std::getline(
is,
str,
_T(
':'));
439 is.clear();
is.setstate(std::ios::failbit);
451 if ((
is >>
I.size_).fail())
454 is.clear();
is.setstate(std::ios::failbit);
457 else {
I.size_ -=
I.begin_ ;}
467template<
int SizeI_,
int SizeJ_>
469{
return Range(std::min(
I.begin(),
J.begin()), std::max(
I.lastIdx(),
J.lastIdx()), 0);}
476template<
int SizeI_,
int SizeJ_>
478{
return Range(std::max(
I.begin(),
J.begin()), std::min(
I.lastIdx(),
J.lastIdx()), 0);}
485{
return Range(
I.begin()+1,
I.lastIdx(), 0);}
492{
return Range(
I.begin(),
I.lastIdx()+1, 0);}
499{
return Range(
I.begin()-1,
I.lastIdx(), 0);}
506{
return Range(
I.begin(),
I.lastIdx()-1, 0);}
518 :
os <<
I.begin() <<
_T(
":") <<
I.lastIdx();
541 typename std::map<String, TRange<Size_> >::const_iterator
it=
mapping.find(
str);
569 typename std::map<TRange<Size_> ,
String>::const_iterator
it=
mapping.find(value);
#define _T(x)
Let x unmodified.
Interface base class for all classes implementing the curious recursive template paradigm.
Derived & asDerived()
static cast : return a reference of this with a cast to the derived class.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Base class for TRange class.
Derived & operator-=(int i)
shift range a:b becomes (a+i):(b+i)
Derived & 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 isIn(TRange< OtherSize_ > const &I) const
check if this TRange in include in an other TRange
RangeBase(int begin)
constructor.
RangeBase()
Default constructor.
int begin() const
get the first index of the TRange.
bool operator==(TRange< OtherSize_ > const &I) const
compare this range with range I
bool isContaining(TRange< OtherSize_ > const &I) const
check if the TRange I is include in the this TRange
RangeBase(RangeBase const &I)
Copy constructor.
bool isContaining(int i) const
Return true if i is in this TRange.
RangeBase(RangeBase< OtherDerived > const &I)
Copy constructor.
Index sub-vector region: Specialization when the size is unknown.
RangeBase< TRange< UnknownSize > > Base
TRange & dec(int dec=1)
create the TRange [begin_+inc, end_).
TRange(TRange< OtherSize_ > const &I)
Copy constructor.
TRange(int first, int last, bool junk)
Complete constructor.
TRange & incLast(int inc=1)
create the TRange [begin_, end_+inc)
TRange & decLast(int dec=1)
create the TRange [begin_, end_-dec)
TRange & decFirst(int dec=1)
create the TRange [begin_-dec, end_)
TRange & inc(int inc=1)
create the TRange [begin_+inc, end_+inc_).
int lastIdx() const
get the last index of the TRange.
TRange & decEnd(int dec=1)
create the TRange [begin_, end_-dec)
bool empty() const
check if the range is empty or not.
int end() const
get the ending index of the TRange.
TRange(TRange const &I)
Copy constructor.
TRange & inf(TRange< OtherSize_ > const &I)
Take the largest value of begin_ and I.begin_ for begin_ and the lowest value of end_ and I....
int size_
theoretic Dimension size_ = end_- begin_
TRange & incEnd(int inc=1)
create the TRange [begin_, end_+inc)
TRange(int size=0)
constructor.
TRange & shift(int first)
Shift the TRange giving the first element: the size is not modified.
int size() const
get the size of the TRange (the number of elements).
TRange & sup(TRange< OtherSize_ > const &I)
Take the lowest value of begin_ and I.begin_ for begin_ and the largest value of end_ and I....
TRange & incFirst(int inc=1)
create the TRange [begin_-dec, end_-dec)
TRange(int first, int size)
Complete constructor.
Index sub-vector region with fixed size.
TRange & incLast(int inc=1)
create the TRange [begin_, end_+inc)
int end() const
get the ending index of the TRange.
TRange & decFirst(int dec=1)
create the TRange [begin_-dec, end_]
TRange(int size=Size_)
Default constructor.
RangeBase< TRange< Size_ > > Base
int size() const
get the size of the TRange (the number of elements).
TRange & dec(int dec=1)
create the TRange [begin_-dec, end_-dec]
TRange(int first, int, bool)
Complete constructor.
TRange & inc(int inc=1)
create the TRange [begin_+inc, end_+inc_].
TRange & incFirst(int inc=1)
create the TRange [begin_+inc, end_].
TRange(TRange const &I)
copy constructor
int lastIdx() const
get the last index of the TRange.
bool empty() const
check if the range is empty or not.
TRange & shift(int begin)
Shift the TRange giving the first element.
TRange(TRange< OtherSize_ > const &I)
copy constructor
TRange(int first, int)
Full constructor.
TRange & decLast(int dec=1)
create the TRange [begin_, end_-dec)
TRange & decEnd(int dec=1)
create the TRange [begin_, end_-dec)
TRange & incEnd(int inc=1)
create the TRange [begin_, end_+inc)
bool isNA(Type const &x)
utility method allowing to know if a value is a NA (Not Available) value
ostream & operator<<(ostream &s, const CAllocator< Type, SizeRows_, SizeCols_, Orient_ > &V)
output stream for CAllocator.
Range stringToRange(String const &str)
Convert a String to a Range.
bool stringToType(Type &t, String const &s, std::ios_base &(*f)(std::ios_base &)=std::dec)
convert a String to Type
String rangeToString(TRange< Size_ > const &value, std::ios_base &(*f)(std::ios_base &)=std::dec)
Convert an Range to a String.
String stringNa
Representation of a Not Available value.
String typeToString< Range >(Range const &t, std::ios_base &(*f)(std::ios_base &))
Specialization for Range.
IdType
Id for the Type of a variable.
Range inf(TRange< SizeI_ > const &I, TRange< SizeJ_ > const &J)
compute inf(I,J).
Range incLast(TRange< SizeI_ > const &I)
if I=a:b, return a:b+1
Range decLast(TRange< SizeI_ > const &I)
if I=a:b, return a:b-1
Range sup(TRange< SizeI_ > const &I, TRange< SizeJ_ > const &J)
compute sup(I,J).
Range incFirst(TRange< SizeI_ > const &I)
if I=a:b, return a+1:b
Range decFirst(TRange< SizeI_ > const &I)
if I=a:b, return a-1:b
std::basic_string< Char > String
STK fundamental type of a String.
const int UnknownSize
This value means that an integer is not known at compile-time, and that instead the value is stored i...
const int firstIdx_
base index of the containers created in STK++.
std::basic_ostream< Char > ostream
ostream for Char
std::basic_ostringstream< Char > ostringstream
ostringstream (ostringstream) for Char
std::basic_istream< Char > istream
istream for Char
The namespace STK is the main domain space of the Statistical ToolKit project.
istream & operator>>(istream &is, Binary &value)
Overloading of the istream >> for the type Binary.
TRange< UnknownSize > Range
static TRange< Size_ > NA()
Adding a Non Available (NA) special number.
static bool isNA(TRange< Size_ > const &x)
Test if x is a Non Available (NA) special number.
static bool isFinite(TRange< Size_ > const &x)
test if x is finite.
static bool isInfinite(TRange< Size_ > const &x)
test if x is infinite.
Arithmetic properties of STK fundamental types.
static bool isInfinite(Type const &x)
static const bool hasNA
True if the type has a representation for a "Not Available."
static Type NA()
Adding a Non Available (NA) special number.
static bool isNA(Type const &x)
static Base::IdType returnType()
Implementation of the return type.