STK++ 0.9.13
STK_SArray2DDiagonal.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 SArray2DDiagonal class.
28 * Author: Serge Iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 *
30 **/
31
36#ifndef STK_SARRAY2DDIAGONAL_H
37#define STK_SARRAY2DDIAGONAL_H
38
39#include "STK_SArray1D.h"
40
41#include "STK_IArray2D.h"
42#include "STK_IArray2DSlicers.h"
44
45namespace STK
46{
47// forward declaration
48template< typename Type> class SArray2DDiagonal;
49template< typename Type> class SArray2DPoint;
50template< typename Type> class SArray2DVector;
51
55
56namespace hidden
57{
61template<class Type_>
62struct Traits<SArray2DDiagonal<Type_> >
63{
64 private:
65 class Void {};
66 public:
73
74 typedef Type_ Type;
75 typedef typename RemoveConst<Type>::Type const& TypeConst;
76
77 enum
78 {
79 structure_ = Arrays::diagonal_,
80 orient_ = Arrays::by_col_,
81 sizeRows_ = UnknownSize,
82 sizeCols_ = UnknownSize,
83 size_ = UnknownSize,
84 storage_ = Arrays::sparse_
85 };
87};
88
89} // namespace hidden
90
100template<class Type_>
101class SArray2DDiagonal: public IArray2D< SArray2DDiagonal<Type_> >
102{
103 public:
107
114
117
118 enum
119 {
124 storage_ = Arrays::dense_ // always dense
125 };
142 SArray2DDiagonal( SArray2DDiagonal const& T, bool ref=false): Base(T, ref) {}
147 SArray2DDiagonal( SArray2DDiagonal const& T, Range const& I): Base(T, I, I) {}
151 template<class OtherDerived>
159 inline Type& elt1Impl(int i) { return this->elt(i,i);}
163 inline Type const& elt1Impl(int i) const { return this->elt(i,i);}
167 void shift1D(int beg) { Base::shift(beg, beg);}
172 { Base::resize(I, I); return *this;}
176 inline void setValue1D( int i, TypeConst v)
177 { this->setValue(i, i, v);}
178
182 void insertElt( int pos, int n =1)
183 {
184 Base::insertCols(pos, n);
185 this->incEndRows(n);
186 Base::update( Range(pos+n, this->lastIdxCols(), 0) );
187 }
192 void erase( int pos, int n=1)
193 {
194 Base::eraseCols(pos, n);
195 this->decEndRows(n);
196 Base::update( Range(pos, this->lastIdxCols(), 0) );
197 }
201 void pushBack(int n=1)
202 {
204 this->incEndRows(n);
205 }
206
210 void popBack(int n=1)
211 {
213 this->decEndRows(n);
214 }
219 template<class Rhs>
230};
231
232} // namespace STK
233
234
235#endif
236// STK_SARRAY2DDIAGONAL_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...
In this file we define and implement the final class SArray1D.
SArray2DDiagonal< Type_ > & operator=(Type const &value)
SArray2DDiagonal< Type_ > & setValue(TypeConst value)
set a value to this container.
SArray2DDiagonal< 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.
SArray2DDiagonal< 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...
Derivation of the SArray2DDiagonal class for square arrays of Real.
hidden::Traits< SArray2DDiagonal< Type_ > >::SubRow SubRow
SArray2DDiagonal(ExprBase< OtherDerived > const &T)
Copy constructor using an expression.
SArray2DDiagonal(SArray2DDiagonal const &T, Range const &I)
constructor by reference, ref_=1 in the range given by I.
SArray2DDiagonal()
Default constructor.
SArray2DDiagonal(Range const &I, Real const &v)
constructor with cols_and rows_ givens, initialization with a constant.
SArray2DDiagonal & operator=(const SArray2DDiagonal &T)
overwrite the SArray2D with T.
void popBack(int n=1)
Delete n rows and columns at the end of the container.
void erase(int pos, int n=1)
Delete n rows and columns at the specified position to the container.
SArray2DDiagonal & resize1D(Range const &I)
New size for the container.
SArray2DDiagonal & operator=(Type const &v)
set the container to a constant value.
IArray2D< SArray2DDiagonal< Type_ > > Base
Type for the Interface Class.
void shift1D(int beg)
New beginning index for the object.
hidden::Traits< SArray2DDiagonal< Type_ > >::TypeConst TypeConst
SArray2DDiagonal(Range const &I)
Constructor with specified range.
ArrayBase< SArray2DDiagonal< Type_ > > LowBase
hidden::Traits< SArray2DDiagonal< Type_ > >::Type Type
hidden::Traits< SArray2DDiagonal< Type_ > >::SubVector SubVector
hidden::Traits< SArray2DDiagonal< Type_ > >::SubArray SubArray
SArray2DDiagonal & 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.
Type const & elt1Impl(int i) const
hidden::Traits< SArray2DDiagonal< Type_ > >::SubCol SubCol
void setValue1D(int i, TypeConst v)
Set value at position i.
SArray2DDiagonal(SArray2DDiagonal const &T, bool ref=false)
Copy constructor.
void insertElt(int pos, int n=1)
Insert n rows and column at the given position to the container.
hidden::Traits< SArray2DDiagonal< Type_ > >::Col Col
hidden::Traits< SArray2DDiagonal< Type_ > >::Row Row
Index sub-vector region: Specialization when the size is unknown.
Definition STK_Range.h:265
@ sparse_
sparse matrix/vector/array/expression
@ 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.
SArray2DDiagonal< Real > SArrayDiagonalX
SArray2DDiagonal< double > SArrayDiagonalXd
SArray2DDiagonal< int > SArrayDiagonalXi
TRange< UnknownSize > Range
Definition STK_Range.h:59
SArray1D< Type, UnknownSize, UnknownSize > ColVector