STK++ 0.9.13
STK_Const_Arrays.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.org (see copyright for ...)
23*/
24
25/*
26 * Project: stkpp::Arrays
27 * created on: 25 juil. 2013
28 * Author: iovleff, serge.iovleff@stkpp.org
29 **/
30
36#ifndef STK_CONST_ARRAYS_H
37#define STK_CONST_ARRAYS_H
38
39#include "STK_ExprBase.h"
40
41namespace STK
42{
43
44// forward declaration
45namespace Const
46{
47template< typename Type_, int Size_ = UnknownSize> class Identity;
48template< typename Type_, int Size_ = UnknownSize> class Square;
49template< typename Type_, int Size_ = UnknownSize> class Vector;
50template< typename Type_, int Size_ = UnknownSize> class Point;
51template< typename Type_, int SizeRows_ = UnknownSize, int SizeCols_ = UnknownSize> class Array;
52template< typename Type_, int SizeRows_ = UnknownSize, int SizeCols_ = UnknownSize> class UpperTriangular;
53template< typename Type_, int SizeRows_ = UnknownSize, int SizeCols_ = UnknownSize> class LowerTriangular;
54
64
74
84
94}
95
96namespace hidden
97{
101template< typename Type_, int Size_>
102struct Traits< Const::Identity <Type_, Size_> >
103{
104 enum
105 {
106 structure_ = Arrays::diagonal_,
107 sizeRows_ = Size_,
108 sizeCols_ = Size_,
109 size_ = Size_,
111 storage_ = Arrays::sparse_
112 };
113
114 typedef Type_ Type;
116};
120template< typename Type_, int Size_>
121struct Traits< Const::Vector <Type_, Size_> >
122{
123 enum
124 {
125 structure_ = Arrays::vector_,
126 sizeRows_ = Size_,
127 sizeCols_ = 1,
128 size_ = Size_,
130 storage_ = Arrays::sparse_
131 };
132 typedef Type_ Type;
134};
138template< typename Type_, int Size_>
139struct Traits< Const::Point <Type_, Size_> >
140{
141 enum
142 {
143 structure_ = Arrays::point_,
144 sizeRows_ = 1,
145 sizeCols_ = Size_,
146 size_ = Size_,
148 storage_ = Arrays::sparse_
149 };
150 typedef Type_ Type;
152};
156template< typename Type_, int Size_>
157struct Traits< Const::Square <Type_, Size_> >
158{
159 enum
160 {
161 structure_ = Arrays::square_,
162 sizeRows_ = Size_,
163 sizeCols_ = Size_,
164 size_ = Size_,
166 storage_ = Arrays::sparse_
167 };
168 typedef Type_ Type;
170};
174template< typename Type_, int SizeRows_, int SizeCols_>
175struct Traits< Const::Array<Type_, SizeRows_, SizeCols_> >
176{
177 enum
178 {
179 structure_ = Arrays::array2D_,
180 sizeRows_ = SizeRows_,
181 sizeCols_ = SizeCols_,
183 storage_ = Arrays::sparse_
184 };
185 typedef Type_ Type;
187};
191template< typename Type_, int SizeRows_, int SizeCols_>
192struct Traits< Const::UpperTriangular<Type_, SizeRows_, SizeCols_> >
193{
194 enum
195 {
197 sizeRows_ = SizeRows_,
198 sizeCols_ = SizeCols_,
200 storage_ = Arrays::sparse_
201 };
202 typedef Type_ Type;
204};
208template< typename Type_, int SizeRows_, int SizeCols_>
209struct Traits< Const::LowerTriangular<Type_, SizeRows_, SizeCols_> >
210{
211 enum
212 {
214 sizeRows_ = SizeRows_,
215 sizeCols_ = SizeCols_,
217 storage_ = Arrays::sparse_
218 };
219 typedef Type_ Type;
221};
222
223} // namespace hidden
224
225namespace Const
226{
227template< class Derived>
228class IConstArray: protected IContainer2D<hidden::Traits<Derived>::sizeRows_, hidden::Traits<Derived>::sizeCols_>, public ExprBase<Derived>
229{
230 public:
231 enum
232 {
238 };
247
248 protected:
252 IConstArray(Range const& rows, Range const& cols): Base2D(rows, cols), Base() {}
255
256 public:
258 inline RowRange const& rowsImpl() const { return Base2D::rows();}
260 inline RowRange const& rows() const { return Base2D::rows();}
262 inline int beginRows() const { return Base2D::beginRows();}
264 inline int endRows() const { return Base2D::endRows();}
266 inline int sizeRows() const { return Base2D::sizeRows();}
267
269 inline ColRange const&colsImpl() const { return Base2D::cols();}
271 inline ColRange const&cols() const { return Base2D::cols();}
273 inline int beginCols() const { return Base2D::beginCols();}
275 inline int endCols() const { return Base2D::endCols();}
277 inline int sizeCols() const { return Base2D::sizeCols();}
278
280 inline int lastIdxCols() const { return Base2D::lastIdxCols();}
282 inline int lastIdxRows() const { return Base2D::lastIdxRows();}
283
285 bool empty() const { return Base2D::empty();}
286};
287
310template< typename Type_, int Size_ >
338
361template< typename Type_, int Size_ >
385
409template< typename Type_, int SizeRows_, int SizeCols_ >
434
458template< typename Type_, int SizeRows_, int SizeCols_ >
483
507template< typename Type_, int SizeRows_, int SizeCols_ >
532
551template< typename Type_, int Size_ >
580
599template< typename Type_, int Size_ >
628
629
630} // namespace const
631
632} // namespace STK
633
634#endif /* STK_CONST_ARRAYS_H */
In this file we define the base class for Arrays and Expressions.
Define the constant general matrix.
IConstArray< Array< Type_, SizeRows_, SizeCols_ > > Base
TypeConst elt2Impl(int i, int j) const
hidden::Traits< Array< Type_, SizeRows_, SizeCols_ > >::TypeConst TypeConst
Array()
default constructor
Array(Range rangeRows, Range rangeCols)
constructor with specified dimension
hidden::Traits< Array< Type_, SizeRows_, SizeCols_ > >::Type Type
hidden::Traits< Derived >::TypeConst TypeConst
ColRange const & cols() const
IConstArray(Range const &rows, Range const &cols)
constructor with specified dimension
ColRange const & colsImpl() const
TRange< sizeCols_ > ColRange
Type of the Range for the columns.
RowRange const & rows() const
ExprBase< Derived > Base
IContainer2D< sizeRows_, sizeCols_ > Base2D
Type for the IContainer2D base Class.
TRange< sizeRows_ > RowRange
Type of the Range for the rows.
RowRange const & rowsImpl() const
IConstArray()
default constructor
Define the constant identity matrix.
hidden::Traits< Identity< Type_, Size_ > >::TypeConst TypeConst
Identity(Range I)
constructor with specified dimension
Identity()
default constructor
hidden::Traits< Identity< Type_, Size_ > >::Type Type
TypeConst elt2Impl(int i, int j) const
IConstArray< Identity< Type_, Size_ > > Base
TypeConst elt1Impl(int i) const
Define the constant lower triangular matrix.
hidden::Traits< LowerTriangular< Type_, SizeRows_, SizeCols_ > >::TypeConst TypeConst
TypeConst elt2Impl(int i, int j) const
LowerTriangular()
default constructor
IConstArray< LowerTriangular< Type_, SizeRows_, SizeCols_ > > Base
hidden::Traits< LowerTriangular< Type_, SizeRows_, SizeCols_ > >::Type Type
LowerTriangular(Range rangeRows, Range rangeCols)
constructor with specified dimension
Define the constant point.
Point(Range I)
constructor with specified dimension
IConstArray< Point< Type_, Size_ > > Base
Point()
default constructor
TypeConst elt1Impl(int j) const
hidden::Traits< Point< Type_, Size_ > >::Type Type
hidden::Traits< Point< Type_, Size_ > >::TypeConst TypeConst
TypeConst elt2Impl(int i, int j) const
Define the constant square matrix.
hidden::Traits< Square< Type_, Size_ > >::Type Type
hidden::Traits< Square< Type_, Size_ > >::TypeConst TypeConst
Square()
default constructor
IConstArray< Square< Type_, Size_ > > Base
TypeConst elt2Impl(int i, int j) const
Square(Range I)
constructor with specified dimension
Define the constant upper triangular matrix.
UpperTriangular()
default constructor
TypeConst elt2Impl(int i, int j) const
IConstArray< UpperTriangular< Type_, SizeRows_, SizeCols_ > > Base
UpperTriangular(Range rangeRows, Range rangeCols)
constructor with specified dimension
hidden::Traits< UpperTriangular< Type_, SizeRows_, SizeCols_ > >::Type Type
hidden::Traits< UpperTriangular< Type_, SizeRows_, SizeCols_ > >::TypeConst TypeConst
Define the constant point.
TypeConst elt2Impl(int i, int j) const
hidden::Traits< Vector< Type_, Size_ > >::Type Type
TypeConst elt1Impl(int i) const
Vector()
default constructor
IConstArray< Vector< Type_, Size_ > > Base
Vector(Range I)
constructor with specified dimension
hidden::Traits< Vector< Type_, Size_ > >::TypeConst TypeConst
base class for template evaluation expressions and visitors.
Interface base class for 2D containers.
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.
@ sparse_
sparse matrix/vector/array/expression
@ array2D_
general matrix/array/expression
@ point_
row oriented vector/array/expression
@ lower_triangular_
lower triangular matrix/array/expression
@ upper_triangular_
upper triangular matrix/array/expression
@ diagonal_
diagonal matrix/array/expression
@ vector_
column oriented vector/array/expression
@ square_
square matrix/array/expression
@ by_row_
storage by row
@ by_col_
storage by column
Vector< int, 3 > Vector3i
Vector< Real, UnknownSize > ConstVectorX
Vector< int, 3 > ConstVector3i
Vector< int, 2 > ConstVector2i
Point< double, UnknownSize > ConstPointXd
Point< int, 2 > ConstPoint2i
Point< Real, UnknownSize > PointX
Point< double, UnknownSize > PointXd
Point< Real, UnknownSize > ConstPointX
Point< double, 2 > Point2d
Point< Real, 3 > ConstPoint3
Point< double, 3 > Point3d
Vector< Real, 2 > ConstVector2
Point< int, UnknownSize > ConstPointXi
Vector< Real, UnknownSize > VectorX
Vector< double, UnknownSize > ConstVectorXd
Point< int, 2 > Point2i
Vector< double, 3 > ConstVector3d
Point< double, 2 > ConstPoint2d
Vector< int, 2 > Vector2i
Vector< Real, 3 > Vector3
Point< int, 3 > ConstPoint3i
Point< double, 3 > ConstPoint3d
Vector< int, UnknownSize > VectorXi
Vector< double, 2 > ConstVector2d
Point< Real, 3 > Point3
Vector< int, UnknownSize > ConstVectorXi
Point< Real, 2 > Point2
Vector< Real, 2 > Vector2
Point< Real, 2 > ConstPoint2
Vector< double, 2 > Vector2d
Point< int, UnknownSize > PointXi
Vector< double, 3 > Vector3d
Vector< Real, 3 > ConstVector3
Point< int, 3 > Point3i
Vector< double, UnknownSize > VectorXd
The namespace STK is the main domain space of the Statistical ToolKit project.