STK++ 0.9.13
STK_ITContainer2D.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff, Université Lille 1, Inria
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
23 */
24
25/*
26 * Project: stkpp::Arrays
27 * created on: 10 août 2012
28 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 **/
30
35#ifndef STK_ITCONTAINER2D_H
36#define STK_ITCONTAINER2D_H
37
38
39namespace STK
40{
41
83template <class Derived>
84class ITContainer2D: public IContainer2D< hidden::Traits<Derived>::sizeRows_
85 , hidden::Traits<Derived>::sizeCols_
86 >
87 , public IRecursiveTemplate<Derived>
88{
89 public:
92
95
96 enum
97 {
103 };
104
109
114
115 protected:
121 inline ITContainer2D( RowRange const& I, ColRange const& J): Base2D(I, J), Base() {}
125 inline ITContainer2D( ITContainer2D const& T): Base2D(T), Base() {}
128
129 public:
133 inline Type& elt(int i, int j)
134 {
135#ifdef STK_BOUNDS_CHECK
136 if (this->beginRows() > i) { STKOUT_OF_RANGE_2ARG(ITContainer2D::elt, i, j, beginRows() > i);}
137 if (this->endRows() <= i) { STKOUT_OF_RANGE_2ARG(ITContainer2D::elt, i, j, endRows() <= i);}
138 if (this->beginCols() > j) { STKOUT_OF_RANGE_2ARG(ITContainer2D::elt, i, j, beginCols() > j);}
139 if (this->endCols() <= j) { STKOUT_OF_RANGE_2ARG(ITContainer2D::elt, i, j, endCols() <= j);}
140#endif
141 return this->asDerived().elt2Impl(i,j);
142 }
146 inline TypeConst elt(int i, int j) const
147 {
148#ifdef STK_BOUNDS_CHECK
149 if (this->beginRows() > i) { STKOUT_OF_RANGE_2ARG(ITContainer2D::elt, i, j, beginRows() > i);}
150 if (this->endRows() <= i) { STKOUT_OF_RANGE_2ARG(ITContainer2D::elt, i, j, endRows() <= i);}
151 if (this->beginCols() > j) { STKOUT_OF_RANGE_2ARG(ITContainer2D::elt, i, j, beginCols() > j);}
152 if (this->endCols() <= j) { STKOUT_OF_RANGE_2ARG(ITContainer2D::elt, i, j, endCols() <= j);}
153#endif
154 return this->asDerived().elt2Impl(i,j);
155 }
159 inline Type& elt(int i) { return this->asDerived().elt1Impl(i);}
165 inline TypeConst elt(int i) const { return this->asDerived().elt1Impl(i);}
167 inline Type& elt() { return this->asDerived().elt0Impl();}
169 inline TypeConst elt() const { return this->asDerived().elt0Impl();}
170
174 Derived& resize(int sizeRows, int sizeCols)
175 { return this->asDerived().resize2Impl(sizeRows, sizeCols);}
179 Derived& resize(int size) { return this->asDerived().resize1Impl(size);}
180
184 void shift( int firstRow, int firstCol) { this->asDerived().shift2Impl(firstRow, firstCol);}
188 void shift(int beg) { this->asDerived().shift1Impl(beg);}
189};
190
191} // namespace STK
192
193#endif /* STK_ITCONTAINER2D_H */
#define STKOUT_OF_RANGE_2ARG(Where, Arg1, Arg2, Error)
Definition STK_Macros.h:102
Interface base class for 2D containers.
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.
Interface base class for homogeneous 2D containers like allocators.
ITContainer2D(ITContainer2D const &T)
Copy constructor.
TypeConst elt(int i) const
IContainer2D< sizeRows_, sizeCols_ > Base2D
Type of the Base container.
TypeConst elt(int i, int j) const
ITContainer2D()
Default constructor.
~ITContainer2D()
destructor.
hidden::Traits< Derived >::TypeConst TypeConst
Derived & resize(int sizeRows, int sizeCols)
resize the container
IRecursiveTemplate< Derived > Base
Type of the Base container.
TypeConst elt() const
void shift(int firstRow, int firstCol)
shift the first indexes of the container
hidden::Traits< Derived >::Col Col
hidden::Traits< Derived >::Row Row
ITContainer2D(RowRange const &I, ColRange const &J)
constructor with specified Range.
void shift(int beg)
shift the first indexes of the 1D container
Derived & resize(int size)
Resize 1D container.
hidden::Traits< Derived >::Type Type
TRange< sizeCols_ > ColRange
Type of the Range for the columns.
Type & elt(int i, int j)
TRange< sizeRows_ > RowRange
Type of the Range for the rows.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
The namespace STK is the main domain space of the Statistical ToolKit project.