STK++ 0.9.13
STK_Array1D.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: 26 nov. 2007
28 * Author: Serge Iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 **/
30
35#ifndef STK_ARRAY1D_H
36#define STK_ARRAY1D_H
37
38#include "STK_IArray1D.h"
39
40namespace STK
41{
42template<class Type_, int Size_ = UnknownSize > class Array1D;
43
44namespace hidden
45{
49template<class Type_, int Size_>
50struct Traits< Array1D<Type_, Size_> >
51{
55
56 typedef Type_ Type;
57 typedef typename RemoveConst<Type>::Type const& TypeConst;
58
59 enum
60 {
61 structure_ = Arrays::vector_,
62 orient_ = Arrays::by_col_,
63 sizeCols_ = 1,
64 sizeRows_ = Size_,
65 size_ = Size_,
66 storage_ = Arrays::dense_ // always dense
67 };
68
70
73
74 typedef int Index;
75
78
79 typedef std::reverse_iterator<Iterator> ReverseIterator;
80 typedef std::reverse_iterator<ConstIterator> ConstReverseIterator;
81};
82
83} // namespace hidden
84
85}
86
87namespace STK
88{
101template<class Type_, int Size_ >
102class Array1D: public IArray1D< Array1D<Type_, Size_> >
103{
104 public:
107
108 enum
109 {
116 };
117
120
123
128
129 // Compatibility naming scheme with STL
134
136 class InnerOperator;
142 Array1D( Range const& I): Base(I) {}
146 Array1D( Range const& I, Type const& v): Base(I, v) {}
151 Array1D( Array1D const& T, bool ref =false): Base(T, ref) {}
156 template<int OtherSize>
157 Array1D( Array1D<Type, OtherSize> const& T, bool ref =false): Base(T, ref) {}
162 template<int OtherSize>
163 Array1D( Array1D<Type, OtherSize> const& T, RowRange const& I, bool ref = true)
164 : Base(T, I, ref) {}
169 Array1D( Allocator const& A, Range const& I, bool ref): Base(A, I, ref) {}
173 Array1D( Type* q, Range const& I): Base(q, I) {}
180 { return this->assign(T);}
184 template<class OtherArray>
186 {
187 // check size
188 if (this->range()!=T.range()) this->resize(T.range());
189 for (int i=this->begin(); i<this->end(); i++) this->elt(i) = T.elt(i);
190 return *this;
191 }
196 {
197 for (int i=this->begin(); i<this->end(); i++) this->elt(i)= v;
198 return *this;
199 }
200};
201
202} // namespace STK
203
204#endif // STK_ARRAY1D_H
Interface base class for the Array1D, this is an internal header file, included by other Containers l...
template one dimensional Arrays.
ReverseIterator reverse_iterator
ConstReverseIterator const_reverse_iterator
Array1D(Array1D const &T, bool ref=false)
Copy constructor.
Array1D(Range const &I, Type const &v)
Misc constructor with beg and end, initialization with a constant.
Array1D(Allocator const &A, Range const &I, bool ref)
Wrapper constructor.
Array1D(Array1D< Type, OtherSize > const &T, bool ref=false)
Copy constructor.
hidden::Traits< Array1D< Type_, Size_ > >::Allocator Allocator
Array1D & operator=(ITContainer1D< OtherArray > const &T)
Copy an other type of 1D array in an Array1D.
Array1D(Range const &I)
constructor with a specified Range
Array1D & operator=(Type const &v)
operator= : set the container to a constant value.
hidden::Traits< Array1D< Type_, Size_ > >::ConstIterator ConstIterator
hidden::Traits< Array1D< Type_, Size_ > >::Type Type
hidden::Traits< Array1D< Type_, Size_ > >::ColRange ColRange
Array1D()
Default constructor.
Iterator iterator
Array1D & operator=(Array1D const &T)
operator = : overwrite the Array1D with T.
Array1D(Type *q, Range const &I)
Wrapper constructor: the container is a reference of a C-Array.
hidden::Traits< Array1D< Type_, Size_ > >::ReverseIterator ReverseIterator
Array1D(Array1D< Type, OtherSize > const &T, RowRange const &I, bool ref=true)
constructor by reference, ref_=1.
hidden::Traits< Array1D< Type_, Size_ > >::RowRange RowRange
ConstIterator const_iterator
hidden::Traits< Array1D< Type_, Size_ > >::ConstReverseIterator ConstReverseIterator
IArray1D< Array1D< Type_, Size_ > > Base
hidden::Traits< Array1D< Type_, Size_ > >::TypeConst TypeConst
~Array1D()
destructor: allocated memory is liberated by MemAllocator base class.
hidden::Traits< Array1D< Type_, Size_ > >::Iterator Iterator
template one dimensional Array.
Array1D< Type_, Size_ > & assign(IArray1D const &src)
overwrite this with src.
Derived & resize(Range const &I=RowRange())
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
@ dense_
dense matrix/vector/array/expression
@ vector_
column oriented vector/array/expression
@ by_col_
storage by column
The namespace STK is the main domain space of the Statistical ToolKit project.
DenseRandomIterator< Array1D< Type_, Size_ > > Iterator
Definition STK_Array1D.h:76
ConstDenseRandomIterator< Array1D< Type_, Size_ > > ConstIterator
Definition STK_Array1D.h:77
Array1D< Type_, UnknownSize > SubVector
Definition STK_Array1D.h:54
std::reverse_iterator< ConstIterator > ConstReverseIterator
Definition STK_Array1D.h:80
RemoveConst< Type >::Type const & TypeConst
Definition STK_Array1D.h:57
std::reverse_iterator< Iterator > ReverseIterator
Definition STK_Array1D.h:79