STK++ 0.9.13
STK_CArraySquare.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_CARRAYSQUARE_H
36#define STK_CARRAYSQUARE_H
37
38#include "STK_ICArray.h"
39
40namespace STK
41{
42// forward declarations
43template< typename Type_, int Size_ = UnknownSize, bool Orient_ = Arrays::by_col_> class CArraySquare;
44template< typename Type, int SizeRows_, int SizeCols_, bool Orient_> class CArray;
45template< typename Type, int SizeCols_, bool Orient_> class CArrayPoint;
46template< typename Type, int SizeRows_, bool Orient_> class CArrayVector;
47template< typename Type, bool Orient_> class CArrayNumber;
48
49// useful typedef
59
69
70namespace hidden
71{
75template<typename Type_, int Size_, bool Orient_>
76struct Traits< CArraySquare<Type_, Size_, Orient_> >
77{
80
81 // The CAllocator have to have the same structure than the CArray
83
84 typedef Type_ Type;
85 typedef typename RemoveConst<Type>::Type const& TypeConst;
86
87 enum
88 {
89 structure_ = Arrays::square_,
90 orient_ = Orient_,
91 sizeRows_ = Size_,
92 sizeCols_ = Size_,
93 size_ = Size_,
94 storage_ = Arrays::dense_
95 };
96};
97
98
99} // namespace hidden
100
104template <typename Type_, int Size_, bool Orient_>
105class CArraySquare: public ICArray < CArraySquare<Type_, Size_, Orient_> >
106{
107 public:
110
113
116
117 enum
118 {
125 };
131 CArraySquare( int const& size): Base(size, size) {}
135 CArraySquare( Range range): Base(range.size(), range.size())
136 { this->shift(range.begin());}
141 CArraySquare( int size, Type const& v): Base(size, size, v) {}
146 CArraySquare( Range range, Type const& v): Base(range.size(), range.size(), v)
147 { this->shift(range.begin());}
152 CArraySquare( CArraySquare const& T, bool ref=false): Base(T, ref) {}
157 CArraySquare( Type* const& q, int size): Base(q, size, size) {}
161 template<class OtherAllocator>
166 template<class OtherDerived>
167 CArraySquare( ExprBase<OtherDerived> const& T): Base(T.sizeRows(), T.sizeCols())
168 { LowBase::operator=(T);}
178 template<class Rhs>
184};
185
186} // namespace STK
187
188
189#endif /* STK_CARRAYSQUARE_H */
Interface base class for the CArray, this is an internal header file, included by other Containers li...
CArraySquare< Type_, Size_, Orient_ > & operator=(Type const &value)
CArraySquare< Type_, Size_, Orient_ > & setValue(TypeConst value)
set a value to this container.
CArraySquare< Type_, Size_, Orient_ > & assign(ExprBase< Rhs > const &rhs)
specialization for the square case.
CArraySquare(CArraySquare const &T, bool ref=false)
Copy constructor.
CArraySquare(int size, Type const &v)
constructor with specified dimension, initialization with a constant.
CArraySquare(int const &size)
constructor with specified dimension.
CArraySquare & operator=(Type const &v)
operator= : set the container to a constant value.
hidden::Traits< CArraySquare< Type_, Size_ > >::Row Row
CArraySquare(ITContainer2D< OtherAllocator > const &allocator)
constructor by reference.
CArraySquare(Range range)
constructor with specified ranges.
~CArraySquare()
destructor.
hidden::Traits< CArraySquare< Type_, Size_ > >::Type Type
CArraySquare & operator=(CArraySquare const &rhs)
operator = : overwrite the CArray with the Right hand side rhs.
ArrayBase< CArraySquare< Type_, Size_, Orient_ > > LowBase
CArraySquare(Type *const &q, int size)
wrapper constructor for 0 based C-Array.
hidden::Traits< CArraySquare< Type_, Size_ > >::TypeConst TypeConst
CArraySquare(ExprBase< OtherDerived > const &T)
Copy constructor using an expression.
hidden::Traits< CArraySquare< Type_, Size_ > >::Col Col
ICArray< CArraySquare< Type_, Size_, Orient_ > > Base
CArraySquare(Range range, Type const &v)
constructor with specified ranges, initialization with a constant.
CArraySquare()
Default constructor.
CArraySquare & operator=(ExprBase< Rhs > const &T)
operator = : overwrite the CArray with the Right hand side T.
CArraySquare< Type_, Size_, 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
@ square_
square matrix/array/expression
The namespace STK is the main domain space of the Statistical ToolKit project.
CArraySquare< double, 3, Arrays::by_row_ > CSquareByRow3d
CArraySquare< int, UnknownSize, Arrays::by_row_ > CSquareByRowXi
CArraySquare< Real, 2, Arrays::by_col_ > CSquare2
CArraySquare< int, 2, Arrays::by_row_ > CSquareByRow2i
CArraySquare< Real, 3, Arrays::by_col_ > CSquare3
CArraySquare< double, 2, Arrays::by_col_ > CSquare2d
CArraySquare< double, UnknownSize, Arrays::by_col_ > CSquareXd
CArraySquare< int, 3, Arrays::by_col_ > CSquare3i
CArraySquare< int, 2, Arrays::by_col_ > CSquare2i
CArraySquare< Real, UnknownSize, Arrays::by_col_ > CSquareX
CArraySquare< int, UnknownSize, Arrays::by_col_ > CSquareXi
CArraySquare< int, 3, Arrays::by_row_ > CSquareByRow3i
CArraySquare< double, 2, Arrays::by_row_ > CSquareByRow2d
CArraySquare< Real, 3, Arrays::by_row_ > CSquareByRow3
CArraySquare< double, 3, Arrays::by_col_ > CSquare3d
CArraySquare< Real, 2, Arrays::by_row_ > CSquareByRow2
CArraySquare< Real, UnknownSize, Arrays::by_row_ > CSquareByRowX
CArraySquare< double, UnknownSize, Arrays::by_row_ > CSquareByRowXd
CAllocator< Type_, Size_, Size_, Orient_ > Allocator