STK++ 0.9.13
STK_IContainer2D.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_ICONTAINER2D_H
36#define STK_ICONTAINER2D_H
37
38namespace STK
39{
40
52template<int SizeRows_, int SizeCols_>
54{
55 public:
60
66 inline IContainer2D( RowRange const& I, ColRange const& J): rows_(I), cols_(J) {}
70 inline IContainer2D( IContainer2D const& T): rows_(T.rows_), cols_(T.cols_) {}
73
75 inline ColRange const& cols() const { return cols_;}
77 inline int beginCols() const { return cols_.begin();}
79 inline int endCols() const { return cols_.end();}
81 inline int sizeCols() const { return cols_.size();}
82
84 inline RowRange const& rows() const { return rows_;}
86 inline int beginRows() const { return rows_.begin();}
88 inline int endRows() const { return rows_.end();}
90 inline int sizeRows() const { return rows_.size();}
91
93 inline int lastIdxCols() const { return cols_.lastIdx();}
95 inline int lastIdxRows() const { return rows_.lastIdx();}
96
98 bool empty() const { return (cols_.empty() || rows_.empty());}
99
100 protected:
104 void shift( int rbeg, int cbeg) { rows_.shift(rbeg); cols_.shift(cbeg);}
108 void setRanges(RowRange const& I = RowRange(), ColRange const& J = ColRange())
109 { rows_ = I; cols_ =J;}
110 // rows
114 void setRows( RowRange const& I = RowRange()) { rows_ = I;}
118 void shiftRows( int beg) { rows_.shift(beg);}
122 void incRangeRows( int inc) { rows_.inc(inc);}
126 void incBeginRows( int inc) { rows_.incFirst(inc);}
130 void decBeginRows( int dec) { rows_.decFirst(dec);}
134 void incEndRows( int inc) { rows_.incLast(inc);}
138 void decEndRows( int dec) { rows_.decLast(dec);}
139 // cols
143 void setCols( ColRange const& J = ColRange()) { cols_ = J;}
147 void shiftCols( int beg) { cols_.shift(beg);}
151 void incRangeCols( int inc) { cols_.inc(inc);}
155 void incBeginCols( int inc) { cols_.incFirst(inc);}
159 void decBeginCols( int dec) { cols_.decFirst(dec);}
163 void incEndCols( int inc) { cols_.incLast(inc);}
167 void decEndCols( int dec) { cols_.decLast(dec);}
168
173 {
174 std::swap(T.rows_, this->rows_ );
175 std::swap(T.cols_, this->cols_ );
176 }
180 void incLastIdxRows( int inc) { rows_.incLast(inc);}
184 void decLastIdxRows( int dec) { rows_.decLast(dec);}
188 void incLastIdxCols( int inc) { cols_.incLast(inc);}
192 void decLastIdxCols( int dec) { cols_.decLast(dec);}
193
194 private:
199};
200
201} // namespace STK
202
203#endif /* STK_ICONTAINER2D_H */
Interface base class for 2D containers.
int lastIdxCols() const
IContainer2D()
Default constructor.
void shiftRows(int beg)
Set the first index of the rows.
void shiftCols(int beg)
Shift the columns first index to beg.
void incEndCols(int inc)
Increment the last index of the columns.
void setRows(RowRange const &I=RowRange())
Set the range of the number of rows.
void decEndRows(int dec)
Decrement the end of the number of rows.
void shift(int rbeg, int cbeg)
Set the first index of the rows and columns.
void decBeginRows(int dec)
Decrement the first index of the number of rows.
int lastIdxRows() const
RowRange rows_
Vertical range : Range of the indexes for the rows.
void incBeginCols(int inc)
increment the first index of the columns.
void decBeginCols(int dec)
Decrement the columns first index.
void incEndRows(int inc)
Increment the end of the number of rows.
TRange< SizeCols_ > ColRange
Type of the Range for the columns.
void decLastIdxRows(int dec)
Decrement the end of the number of rows.
void incRangeRows(int inc)
Increment the range of the number of rows.
void incRangeCols(int inc)
Increment the columns range.
void decEndCols(int dec)
Decrement the last index of the columns.
void setRanges(RowRange const &I=RowRange(), ColRange const &J=ColRange())
Set the ranges of the container.
void decLastIdxCols(int dec)
Decrement the last index of the columns.
void incBeginRows(int inc)
Increment the first index of the number of rows.
RowRange const & rows() const
ColRange cols_
Horizontal range : Range of the indexes for the columns.
IContainer2D(RowRange const &I, ColRange const &J)
Constructor with specified ranges.
void incLastIdxRows(int inc)
Increment the end of the number of rows.
ColRange const & cols() const
void exchange(IContainer2D &T)
exchange this container with T
~IContainer2D()
destructor.
IContainer2D(IContainer2D const &T)
Copy constructor.
TRange< SizeRows_ > RowRange
Type of the Range for the rows.
void setCols(ColRange const &J=ColRange())
Set the columns range.
void incLastIdxCols(int inc)
Increment the last index of the columns.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
int begin() const
get the first index of the TRange.
Definition STK_Range.h:93
TRange & incLast(int inc=1)
create the TRange [begin_, end_+inc)
Definition STK_Range.h:242
int end() const
get the ending index of the TRange.
Definition STK_Range.h:192
TRange & decFirst(int dec=1)
create the TRange [begin_-dec, end_]
Definition STK_Range.h:227
int size() const
get the size of the TRange (the number of elements).
Definition STK_Range.h:196
TRange & inc(int inc=1)
create the TRange [begin_+inc, end_+inc_].
Definition STK_Range.h:214
TRange & incFirst(int inc=1)
create the TRange [begin_+inc, end_].
Definition STK_Range.h:223
int lastIdx() const
get the last index of the TRange.
Definition STK_Range.h:206
bool empty() const
check if the range is empty or not.
Definition STK_Range.h:200
TRange & shift(int begin)
Shift the TRange giving the first element.
Definition STK_Range.h:210
TRange & decLast(int dec=1)
create the TRange [begin_, end_-dec)
Definition STK_Range.h:246
The namespace STK is the main domain space of the Statistical ToolKit project.