STK++ 0.9.13
STK_CArrayVector.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: 25 nov. 2011
28 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 **/
30
35#ifndef STK_CARRAYVECTOR_H
36#define STK_CARRAYVECTOR_H
37
38#include "STK_ICArray.h"
39
40namespace STK
41{
42// forward declaration
43template< typename Type, int SizeRows_=UnknownSize, bool Orient_ = Arrays::by_col_> class CArrayVector;
44template< typename Type, bool Orient_> class CArrayNumber;
45
46// useful typedef
56
66
67namespace hidden
68{
72template<typename Type_, int SizeRows_, bool Orient_>
74{
77
78 // The CAllocator have to have the same structure than the CArray
80
81 typedef Type_ Type;
82 typedef typename RemoveConst<Type>::Type const& TypeConst;
83
84 enum
85 {
86 structure_ = Arrays::vector_,
87 orient_ = Orient_,
88 sizeRows_ = SizeRows_,
89 sizeCols_ = 1,
90 size_ = SizeRows_,
91 storage_ = Arrays::dense_
92 };
93};
94
95
96} // namespace hidden
97
101template <typename Type_, int SizeRows_, bool Orient_>
102class CArrayVector: public ICArray < CArrayVector<Type_, SizeRows_, Orient_> >
103{
104 public:
107
112
113 enum
114 {
121 };
122
128 CArrayVector( int sizeRows): Base(sizeRows, 1) {}
132 CArrayVector( Range range): Base(range.size(), 1)
133 { this->shift(range.begin());}
138 CArrayVector( int sizeRows, Type const& v): Base(sizeRows, 1, v) {}
143 CArrayVector( Range range, Type const& v): Base(range.size(), 1, v)
144 { this->shift(range.begin());}
149 CArrayVector( const CArrayVector &T, bool ref=false): Base(T, ref) {}
154 CArrayVector( CArrayVector const& T, Range const& I)
155 : Base(T.allocator(), I, T.cols())
156 {}
162 template<class OtherArray>
164 : Base(T.allocator(), I, Range(col, 1))
165 {}
170 CArrayVector( Type* const& q, int nbRow): Base(q, nbRow, 1) {}
174 template<class OtherAllocator>
179 template<class OtherDerived>
190 template<class Rhs>
196};
197
198} // namespace STK
199
200
201#endif /* STK_CARRAYVECTOR_H */
Interface base class for the CArray, this is an internal header file, included by other Containers li...
CArrayVector< Type_, SizeRows_, Orient_ > & operator=(Type const &value)
CArrayVector< Type_, SizeRows_, Orient_ > & setValue(TypeConst value)
set a value to this container.
CArrayVector< Type_, SizeRows_, Orient_ > & assign(ExprBase< Rhs > const &rhs)
specialization for the vector case.
CArrayVector & operator=(Type const &v)
operator= : set the container to a constant value.
CArrayVector(ITContainer2D< OtherAllocator > const &allocator)
constructor by reference.
CArrayVector(ICArray< OtherArray > const &T, Range const &I, int col)
constructor by reference, ref_=1.
hidden::Traits< CArrayVector< Type_, SizeRows_, Orient_ > >::Col Col
CArrayVector(ExprBase< OtherDerived > const &T)
Copy constructor using an expression.
CArrayVector(Range range)
constructor with specified ranges.
hidden::Traits< CArrayVector< Type_, SizeRows_, Orient_ > >::TypeConst TypeConst
CArrayVector(int sizeRows, Type const &v)
constructor with sizeRows specified, initialization with a constant.
ICArray< CArrayVector< Type_, SizeRows_, Orient_ > > Base
hidden::Traits< CArrayVector< Type_, SizeRows_, Orient_ > >::Type Type
CArrayVector(CArrayVector const &T, Range const &I)
constructor by reference, ref_=1.
CArrayVector(const CArrayVector &T, bool ref=false)
Copy constructor.
CArrayVector & operator=(ExprBase< Rhs > const &T)
operator = : overwrite the CArrayVector with the Right hand side T.
CArrayVector & operator=(CArrayVector const &rhs)
operator = : overwrite the CArray with the Right hand side rhs.
CArrayVector()
Default constructor.
CArrayVector(int sizeRows)
constructor with specified dimension.
CArrayVector(Type *const &q, int nbRow)
wrapper constructor for 0 based C-Array.
hidden::Traits< CArrayVector< Type_, SizeRows_, Orient_ > >::Row Row
CArrayVector(Range range, Type const &v)
constructor with range specified, initialization with a constant.
ArrayBase< CArrayVector< Type_, SizeRows_, Orient_ > > LowBase
~CArrayVector()
destructor.
hidden::CSlice< CArrayVector< Type_, SizeRows_, Orient_ >, sizeRows_, 1 >::Result col(int j) const
implement the col operator using a reference on the column of the allocator
CArrayVector< Type_, SizeRows_, Orient_ > & shift(int beginRows, int beginCols)
shift the Array.
Allocator const & allocator() const
Get a constant reference on the main allocator.
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
Index sub-vector region: Specialization when the size is unknown.
Definition STK_Range.h:265
@ dense_
dense matrix/vector/array/expression
@ vector_
column oriented vector/array/expression
The namespace STK is the main domain space of the Statistical ToolKit project.
CArrayVector< int, 2, Arrays::by_col_ > CVector2i
CArrayVector< double, UnknownSize, Arrays::by_col_ > CVectorXd
CArrayVector< int, UnknownSize, Arrays::by_col_ > CVectorXi
CArrayVector< int, 3, Arrays::by_col_ > CVector3i
CArrayVector< Real, 3, Arrays::by_row_ > CVectorByRow3
CArrayVector< int, 2, Arrays::by_row_ > CVectorByRow2i
CArrayVector< double, 3, Arrays::by_row_ > CVectorByRow3d
CArrayVector< Real, 2, Arrays::by_row_ > CVectorByRow2
CArrayVector< double, 2, Arrays::by_row_ > CVectorByRow2d
CArrayVector< double, 3, Arrays::by_col_ > CVector3d
CArrayVector< Real, 3, Arrays::by_col_ > CVector3
CArrayVector< int, 3, Arrays::by_row_ > CVectorByRow3i
CArrayVector< Real, UnknownSize, Arrays::by_col_ > CVectorX
CArrayVector< Real, UnknownSize, Arrays::by_row_ > CVectorByRowX
CArrayVector< int, UnknownSize, Arrays::by_row_ > CVectorByRowXi
CArrayVector< double, 2, Arrays::by_col_ > CVector2d
CArrayVector< double, UnknownSize, Arrays::by_row_ > CVectorByRowXd
CArrayVector< Real, 2, Arrays::by_col_ > CVector2