STK++ 0.9.13
STK_Array2DVector.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 * Purpose: Define the Array2DVector class.
28 * Author: Serge Iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 *
30 **/
31
39#ifndef STK_ARRAY2DVECTOR_H
40#define STK_ARRAY2DVECTOR_H
41
42#include "STK_IArray2D.h"
43#include "STK_IArray2DSlicers.h"
45
46namespace STK
47{
48
49template<typename> class Array2DPoint;
50template<typename> class Array2DVector;
51
52
58typedef Array2DVector<Real> Vector; // [DEPRECATED]
62
63namespace hidden
64{
68template<class Type_>
69struct Traits< Array2DVector<Type_> >
70{
77
78 typedef Type_ Type;
79 typedef typename RemoveConst<Type>::Type const& TypeConst;
80
81 enum
82 {
83 structure_ = Arrays::vector_,
84 orient_ = Arrays::by_col_,
85 sizeCols_ = 1,
86 sizeRows_ = UnknownSize,
87 size_ = UnknownSize,
88 storage_ = Arrays::dense_ // always dense
89 };
91};
92
93} // namespace hidden
94
105template<class Type_>
106class Array2DVector: public IArray2D< Array2DVector<Type_> >
107{
108 public:
111
118
121
122 enum
123 {
130 };
131 using Base::elt;
137 Array2DVector( Range const& I): Base(I, Range(1)) {}
142 Array2DVector( Range const& I, Type const& v): Base(I, Range(1))
148 Array2DVector( const Array2DVector &T, bool ref =false)
149 : Base(T, ref) {}
155 : Base(T, I, T.cols())
156 {}
162 template<class OtherArray>
164 : Base(T, I, Range(col, 1))
165 {}
169 template<class OtherDerived>
177 Array2DVector( Type** p_data, Range const& I, int col)
178 : Base(p_data, I, Range(col, 1))
179 {}
182
186 Type const& elt1Impl( int i) const { return this->elt(i, this->beginCols());}
190 inline Type& elt1Impl( int i) { return this->elt(i, this->beginCols());}
194 void shift1D( int rbeg) { Base::shift(rbeg, this->beginCols());}
199 { Base::resize(I, this->cols()); return *this;}
204 { this->setValue(i, this->beginCols(), v);}
205
209 void pushBack( int n=1) { Base::pushBackRows(n);}
214 void erase( int pos, int const& n=1) { Base::eraseRows(pos, n);}
221 void insertElt(int pos, int const& n =1)
222 { Base::insertRows(pos, n);}
226 template<class Rhs>
236};
237
238} // namespace STK
239
240#endif // STK_ARRAY2DVECTOR_H
In this file we implement the modifiers of the IArray2D.
In this file we implement the slicing methods for IArray2D class.
Interface base class for the Array2D classes, this is an internal header file, included by other cont...
template one dimensional horizontal Array.
hidden::Traits< Array2DVector< Type_ > >::SubArray SubArray
Array2DVector(IArray2D< OtherArray > const &T, Range const &I, int col)
constructor by reference, ref_=1.
Array2DVector(ExprBase< OtherDerived > const &T)
Copy constructor using an expression.
Array2DVector & operator=(Type const &v)
set the container to a constant value.
hidden::Traits< Array2DVector< Type_ > >::SubRow SubRow
hidden::Traits< Array2DVector< Type_ > >::Row Row
Array2DVector()
Default constructor.
void shift1D(int rbeg)
New first index for the object.
void insertElt(int pos, int const &n=1)
Insert n elements at the position pos of the container.
void setValue1D(int i, TypeConst v)
Set value at position i.
ArrayBase< Array2DVector< Type_ > > LowBase
hidden::Traits< Array2DVector< Type_ > >::SubVector SubVector
Array2DVector & operator=(ExprBase< Rhs > const &T)
operator = : overwrite the CArray with the Right hand side T.
hidden::Traits< Array2DVector< Type_ > >::TypeConst TypeConst
Type const & elt1Impl(int i) const
hidden::Traits< Array2DVector< Type_ > >::Type Type
Array2DVector(Range const &I, Type const &v)
constructor with specified range, initialization with a constant.
void pushBack(int n=1)
Add n elements to the container.
hidden::Traits< Array2DVector< Type_ > >::SubCol SubCol
Array2DVector(const Array2DVector &T, bool ref=false)
Copy constructor.
Array2DVector< Type > & resize1D(Range const &I)
Resize the container.
Array2DVector & operator=(Array2DVector const &T)
operator = : overwrite the CArray with the Right hand side T.
void erase(int pos, int const &n=1)
Delete n elements at the pos index to the container.
Array2DVector(Type **p_data, Range const &I, int col)
constructor by reference, ref_=1.
hidden::Traits< Array2DVector< Type_ > >::Col Col
Array2DVector(const Array2DVector &T, Range const &I)
constructor by reference, ref_=1.
Array2DVector(Range const &I)
constructor with specified range.
IArray2D< Array2DVector< Type_ > > Base
~Array2DVector()
destructor.
Array2DVector< Type_ > & operator=(Type const &value)
Array2DVector< Type_ > & setValue(TypeConst value)
set a value to this container.
Array2DVector< Type_ > & assign(ExprBase< Rhs > const &rhs)
template interface base class for two-dimensional arrays.
Array2DVector< Type_ > & resize(Range const &I, Range const &J)
resize the array.
void pushBackRows(int n=1)
Add n rows to the array.
Col col(int j) const
access to a part of a column.
void eraseRows(int pos, int n=1)
Delete n rows at the position pos.
void shift(int rbeg, int cbeg)
Set new beginning indexes to the array.
void insertRows(int pos, int n=1)
Insert n rows at position pos in the array If pos is outside the range of a column,...
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
Array2DVector< Real > Vector
final class for a Real vertical container.
@ dense_
dense matrix/vector/array/expression
@ vector_
column oriented vector/array/expression
@ by_col_
storage by column
const int UnknownSize
This value means that an integer is not known at compile-time, and that instead the value is stored i...
The namespace STK is the main domain space of the Statistical ToolKit project.
Array2DVector< double > VectorXd
Array2DVector< int > VectorXi
Array2DVector< Real > VectorX
RemoveConst< Type >::Type const & TypeConst