STK++ 0.9.13
STK_Array2DDiagonal.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 Array2DDiagonal class.
28 * Author: Serge Iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 *
30 **/
31
36#ifndef STK_ARRAY2DDIAGONAL_H
37#define STK_ARRAY2DDIAGONAL_H
38
39#include "STK_IArray2D.h"
40#include "STK_IArray2DSlicers.h"
42
43namespace STK
44{
45// forward declaration
46template< typename Type> class Array2DDiagonal;
47template< typename Type> class Array2DPoint;
48template< typename Type> class Array2DVector;
49
53
54namespace hidden
55{
59template<class Type_>
60struct Traits<Array2DDiagonal<Type_> >
61{
62 private:
63 class Void {};
64 public:
71
72 typedef Type_ Type;
73 typedef typename RemoveConst<Type>::Type const& TypeConst;
74
75 enum
76 {
77 structure_ = Arrays::diagonal_,
78 orient_ = Arrays::by_col_,
79 sizeRows_ = UnknownSize,
80 sizeCols_ = UnknownSize,
81 size_ = UnknownSize,
82 storage_ = Arrays::dense_ // always dense
83 };
85};
86
87} // namespace hidden
88
98template<class Type_>
99class Array2DDiagonal: public IArray2D< Array2DDiagonal<Type_> >
100{
101 public:
105
112
115
116 enum
117 {
122 storage_ = Arrays::dense_ // always dense
123 };
129 Array2DDiagonal( Range const& I): Base(I, I) {}
140 Array2DDiagonal( Array2DDiagonal const& T, bool ref=false): Base(T, ref) {}
145 Array2DDiagonal( Array2DDiagonal const& T, Range const& I): Base(T, I, I) {}
149 template<class OtherDerived>
157 inline Type& elt1Impl(int i) { return this->elt(i,i);}
161 inline Type const& elt1Impl(int i) const { return this->elt(i,i);}
165 void shift1D(int beg) { Base::shift(beg, beg);}
170 { Base::resize(I, I); return *this;}
175 { this->setValue(i, i, v);}
176
180 void insertElt( int pos, int n =1)
181 {
182 Base::insertCols(pos, n);
183 this->incEndRows(n);
184 Base::update( Range(pos+n, this->lastIdxCols(), 0) );
185 }
190 void erase( int pos, int n=1)
191 {
192 Base::eraseCols(pos, n);
193 this->decEndRows(n);
194 Base::update( Range(pos, this->lastIdxCols(), 0) );
195 }
199 void pushBack(int n=1)
200 {
202 this->incEndRows(n);
203 }
204
208 void popBack(int n=1)
209 {
211 this->decEndRows(n);
212 }
217 template<class Rhs>
228};
229
230} // namespace STK
231
232
233#endif
234// STK_ARRAY2DDIAGONAL_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...
Derivation of the Array2DDiagonal class for square arrays of Real.
hidden::Traits< Array2DDiagonal< Type_ > >::SubVector SubVector
void setValue1D(int i, TypeConst v)
Set value at position i.
IArray2D< Array2DDiagonal< Type_ > > Base
Type for the Interface Class.
void popBack(int n=1)
Delete n rows and columns at the end of the container.
Array2DDiagonal & operator=(const Array2DDiagonal &T)
overwrite the Array2D with T.
Array2DDiagonal(Array2DDiagonal const &T, bool ref=false)
Copy constructor.
Array2DDiagonal & resize1D(Range const &I)
New size for the container.
Array2DDiagonal & operator=(Type const &v)
set the container to a constant value.
hidden::Traits< Array2DDiagonal< Type_ > >::Type Type
Array2DDiagonal(Range const &I, Real const &v)
constructor with cols_and rows_ givens, initialization with a constant.
Array2DDiagonal()
Default constructor.
Array2DDiagonal & operator=(ExprBase< Rhs > const &T)
operator = : overwrite the CArray with the Right hand side T.
void pushBack(int n=1)
Add n rows and columns to the container.
hidden::Traits< Array2DDiagonal< Type_ > >::TypeConst TypeConst
Array2DDiagonal(ExprBase< OtherDerived > const &T)
Copy constructor using an expression.
hidden::Traits< Array2DDiagonal< Type_ > >::Col Col
Array2DDiagonal(Range const &I)
Constructor with specified range.
void insertElt(int pos, int n=1)
Insert n rows and column at the given position to the container.
void erase(int pos, int n=1)
Delete n rows and columns at the specified position to the container.
Array2DDiagonal(Array2DDiagonal const &T, Range const &I)
constructor by reference, ref_=1 in the range given by I.
void shift1D(int beg)
New beginning index for the object.
hidden::Traits< Array2DDiagonal< Type_ > >::Row Row
ArrayBase< Array2DDiagonal< Type_ > > LowBase
hidden::Traits< Array2DDiagonal< Type_ > >::SubRow SubRow
hidden::Traits< Array2DDiagonal< Type_ > >::SubArray SubArray
Type const & elt1Impl(int i) const
hidden::Traits< Array2DDiagonal< Type_ > >::SubCol SubCol
Array2DDiagonal< Type_ > & operator=(Type const &value)
Array2DDiagonal< Type_ > & setValue(TypeConst value)
set a value to this container.
Array2DDiagonal< Type_ > & assign(ExprBase< Rhs > const &rhs)
template interface base class for two-dimensional arrays.
void insertCols(int pos, int n=1)
Insert n columns at the index pos to the array.
Array2DDiagonal< Type_ > & resize(Range const &I, Range const &J)
resize the array.
void pushBackCols(int n=1)
Add n columns at the end of the array.
void popBackCols(int n=1)
Delete last columns of the array.
void update(Range const &J)
Update columns of the array at a specified range.
void shift(int rbeg, int cbeg)
Set new beginning indexes to the array.
void eraseCols(int pos, int n=1)
Delete n columns at the specified position of the array.
void decEndRows(int dec)
Decrement the end of the number of rows.
void incEndRows(int inc)
Increment the end of the number of rows.
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
@ diagonal_
diagonal matrix/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...
double Real
STK fundamental type of Real values.
The namespace STK is the main domain space of the Statistical ToolKit project.
Array2DDiagonal< int > ArrayDiagonalXi
Array2DDiagonal< Real > ArrayDiagonalX
TRange< UnknownSize > Range
Definition STK_Range.h:59
Array2DDiagonal< double > ArrayDiagonalXd