STK++ 0.9.13
STK_ArrayBaseApplier.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: 27 sept. 2012
28 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 **/
30
35#ifndef STK_ARRAYBASEAPPLIER_H
36#define STK_ARRAYBASEAPPLIER_H
37
38namespace STK
39{
40
41/* Apply the Visitor @c visitor to the whole coefficients of the array.
42 * The template parameter @c Visitor is the type of the visitor and provides
43 * the following interface:
44 * @code
45 * struct MyVisitor {
46 * // called for all coefficients
47 * Type const& value operator() ();
48 * };
49 * @endcode
50 *
51 * @note visitors offer automatic unrolling for small fixed size matrix.
52 *
53 * @sa setValue, setOnes(), setZeros()
54 */
55template<typename Derived>
56template<typename Visitor>
58{
60 Impl::apply(this->asDerived(), visitor);
61}
62
63/*
64 * start public function of the ArrayBase class using visitor
65 */
66/* @brief Set the value to all the Allocator */
67template<typename Derived>
69{
71 apply(visitor);
72 return this->asDerived();
73}
74
75/* @brief Set the value one to all the Array */
76template<typename Derived>
78{
80 apply(visitor);
81 return this->asDerived();
82}
83
84/* @brief Set the value one to all the Array */
85template<typename Derived>
87{
89 apply(visitor);
90 return this->asDerived();
91}
92
93/* @brief Set the value one to all the Array */
94template<typename Derived>
95inline Derived& ArrayBase<Derived>::ones()
96{ return setOnes();}
97
98/* @brief Set the value one to all the Array */
99template<typename Derived>
101{ return setZeros();}
102
103template<typename Derived>
105{
107 apply(visitor);
108 return this->asDerived();
109}
110
111/* set Gaussian random values to this */
112template<typename Derived>
114{
116 apply(visitor);
117 return this->asDerived();
118}
120/* set random values to this using a law given by the user */
121template<typename Derived>
125 apply(visitor);
126 return this->asDerived();
127}
129
130} // namespace STK
131
132#endif /* STK_ARRAYBASEAPPLIER_H */
Derived & zeros()
set zero to this using a Visitor.
Derived & setValue(TypeConst value)
set a value to this container.
Derived & ones()
set one to this using a Visitor.
hidden::Traits< Derived >::Type Type
Derived & randUnif()
set random values to this using a uniform law.
void apply(Visitor &visitor)
Apply the Visitor visitor to the whole coefficients of the array.
Derived & setZeros()
set zero to this using a Visitor.
hidden::Traits< Derived >::TypeConst TypeConst
Derived & randGauss()
set random values to this using a standard gaussian law.
Derived & rand(Law::IUnivLaw< Type > const &law)
set random values to this using a distribution law given by the user.
Derived & setOnes()
set one to this using a Visitor.
Interface base class for all the univariate distributions.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
The namespace STK is the main domain space of the Statistical ToolKit project.
Visitor putting a choosen random variable.
Visitor setting Gaussian random variables.
Applier setting uniform random numbers.
visitor putting a constant value
If< is2D_ &&unrollRows_ &&unrollCols_, ArrayImpl, HelperImpl >::Result Impl