STK++ 0.9.13
STK_BinarySelector.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: 21 jan. 2018
28 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 **/
30
37#ifndef STK_BINARYSELECTOR_H
38#define STK_BINARYSELECTOR_H
39
40
41namespace STK
42{
43
44namespace hidden
45{
50template<typename Lhs, typename Rhs, int operatorType_>
52
55template<typename Functor, typename Lhs, typename Rhs, bool isNumber>
57
58template<typename Functor, typename Lhs, typename Rhs>
59struct OperatorImpl<Functor, Lhs, Rhs, true>
60{
63
65
66 inline static Result const run( ExprBase<Lhs> const& lhs, ExprBase<Rhs> const& rhs)
67 { return Result(lhs.asDerived(), Functor(rhs.elt()) );}
68};
69
70template<typename Functor, typename Lhs, typename Rhs>
71struct OperatorImpl<Functor, Lhs, Rhs, false>
72{
75
77
78 inline static Result const run( ExprBase<Lhs> const& lhs, ExprBase<Rhs> const& rhs)
79 { return Result(lhs.asDerived(), rhs.asDerived());}
80};
81
84template<typename Lhs, typename Rhs, typename UnaryFunctor, typename BinaryFunctor>
86{
87 enum
88 {
90 };
93
96
99
100 inline static Result const run( ExprBase<Lhs> const& lhs, ExprBase<Rhs> const& rhs)
101 { return OperatorImpl<Functor, Lhs, Rhs, bool(isUnary_)>::run( lhs, rhs);}
102
103 inline static BinaryResult const binaryRun( ExprBase<Lhs> const& lhs, ExprBase<Rhs> const& rhs)
104 { return BinaryResult(lhs.asDerived(), rhs.asDerived());}
105
106 inline UnaryResult const unaryRun( ExprBase<Lhs> const& lhs, ExprBase<Rhs> const& rhs)
107 { return UnaryResult(lhs.asDerived(), UnaryFunctor(lhs.elt()));}
108};
109
113template<typename Lhs, typename Rhs>
114struct OperatorSelector<Lhs, Rhs, Arrays::equalOp_>
115{
116 typedef OperatorHelper< Lhs
117 , Rhs
121 typedef typename Selector::Result Result;
122};
126template<typename Lhs, typename Rhs>
127struct OperatorSelector<Lhs, Rhs, Arrays::notEqualOp_>
128{
129 typedef OperatorHelper< Lhs
130 , Rhs
134 typedef typename Selector::Result Result;
135};
139template<typename Lhs, typename Rhs>
140struct OperatorSelector<Lhs, Rhs, Arrays::greaterThanOp_>
141{
142 typedef OperatorHelper< Lhs
143 , Rhs
147 typedef typename Selector::Result Result;
148};
152template<typename Lhs, typename Rhs>
153struct OperatorSelector<Lhs, Rhs, Arrays::lessThanOp_>
154{
155 typedef OperatorHelper< Lhs
156 , Rhs
160 typedef typename Selector::Result Result;
161};
165template<typename Lhs, typename Rhs>
166struct OperatorSelector<Lhs, Rhs, Arrays::greaterThanOrEqualOp_>
167{
168 typedef OperatorHelper< Lhs
169 , Rhs
173 typedef typename Selector::Result Result;
174};
178template<typename Lhs, typename Rhs>
179struct OperatorSelector<Lhs, Rhs, Arrays::lessThanOrEqualOp_>
180{
181 typedef OperatorHelper< Lhs
182 , Rhs
186 typedef typename Selector::Result Result;
187};
191template<typename Lhs, typename Rhs>
192struct OperatorSelector<Lhs, Rhs, Arrays::sumOp_>
193{
194 typedef OperatorHelper< Lhs
195 , Rhs
199 typedef typename Selector::Result Result;
200};
204template<typename Lhs, typename Rhs>
205struct OperatorSelector<Lhs, Rhs, Arrays::differenceOp_>
206{
207 typedef OperatorHelper< Lhs
208 , Rhs
212 typedef typename Selector::Result Result;
213};
217template<typename Lhs, typename Rhs>
218struct OperatorSelector<Lhs, Rhs, Arrays::productOp_>
219{
220 typedef OperatorHelper< Lhs
221 , Rhs
225 typedef typename Selector::Result Result;
226};
230template<typename Lhs, typename Rhs>
231struct OperatorSelector<Lhs, Rhs, Arrays::divisionOp_>
232{
233 typedef OperatorHelper< Lhs
234 , Rhs
238 typedef typename Selector::Result Result;
239};
243template<typename Lhs, typename Rhs>
244struct OperatorSelector<Lhs, Rhs, Arrays::moduloOp_>
245{
246 typedef OperatorHelper< Lhs
247 , Rhs
251 typedef typename Selector::Result Result;
252};
256template<typename Lhs, typename Rhs>
257struct OperatorSelector<Lhs, Rhs, Arrays::minOp_>
258{
259 typedef OperatorHelper< Lhs
260 , Rhs
264 typedef typename Selector::Result Result;
265};
269template<typename Lhs, typename Rhs>
270struct OperatorSelector<Lhs, Rhs, Arrays::maxOp_>
271{
272 typedef OperatorHelper< Lhs
273 , Rhs
277 typedef typename Selector::Result Result;
278};
282template<typename Lhs, typename Rhs>
283struct OperatorSelector<Lhs, Rhs, Arrays::logicalAndOp_>
284{
285 typedef OperatorHelper< Lhs
286 , Rhs
290 typedef typename Selector::Result Result;
291};
295template<typename Lhs, typename Rhs>
296struct OperatorSelector<Lhs, Rhs, Arrays::logicalOrOp_>
297{
298 typedef OperatorHelper< Lhs
299 , Rhs
303 typedef typename Selector::Result Result;
304};
308template<typename Lhs, typename Rhs>
309struct OperatorSelector<Lhs, Rhs, Arrays::bitwiseAndOp_>
310{
311 typedef OperatorHelper< Lhs
312 , Rhs
316 typedef typename Selector::Result Result;
317};
321template<typename Lhs, typename Rhs>
322struct OperatorSelector<Lhs, Rhs, Arrays::bitwiseOrOp_>
323{
324 typedef OperatorHelper< Lhs
325 , Rhs
329 typedef typename Selector::Result Result;
330};
334template<typename Lhs, typename Rhs>
335struct OperatorSelector<Lhs, Rhs, Arrays::bitwiseXorOp_>
336{
337 typedef OperatorHelper< Lhs
338 , Rhs
342 typedef typename Selector::Result Result;
343};
344
345} // namespace hidden
346
347
348} // namespace STK
349
350#endif /* STK_BINARYSELECTOR_H */
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
@ number_
(1,1) matrix/vector/array/expression (like a number)
The namespace STK is the main domain space of the Statistical ToolKit project.
allow to disambiguate the case expr + number from the case expr + other_expr
UnaryResult const unaryRun(ExprBase< Lhs > const &lhs, ExprBase< Rhs > const &rhs)
If< bool(isUnary_), UnaryResult, BinaryResult >::Result Result
hidden::Traits< Rhs >::Type RType
static BinaryResult const binaryRun(ExprBase< Lhs > const &lhs, ExprBase< Rhs > const &rhs)
If< bool(isUnary_), UnaryFunctor, BinaryFunctor >::Result Functor
hidden::Traits< Lhs >::Type LType
UnaryOperator< UnaryFunctor, Lhs > UnaryResult
BinaryOperator< BinaryFunctor, Lhs, Rhs > BinaryResult
static Result const run(ExprBase< Lhs > const &lhs, ExprBase< Rhs > const &rhs)
static Result const run(ExprBase< Lhs > const &lhs, ExprBase< Rhs > const &rhs)
static Result const run(ExprBase< Lhs > const &lhs, ExprBase< Rhs > const &rhs)
allow to disambiguate the case expr + number from the case expr + other_expr
OperatorHelper< Lhs, Rhs, BitwiseAndWithOp< typename hidden::Traits< Lhs >::Type >, BitwiseAndOp< typename hidden::Traits< Rhs >::Type, typename hidden::Traits< Rhs >::Type > > Selector
OperatorHelper< Lhs, Rhs, BitwiseOrWithOp< typename hidden::Traits< Lhs >::Type >, BitwiseOrOp< typename hidden::Traits< Rhs >::Type, typename hidden::Traits< Rhs >::Type > > Selector
OperatorHelper< Lhs, Rhs, BitwiseXorWithOp< typename hidden::Traits< Lhs >::Type >, BitwiseXorOp< typename hidden::Traits< Rhs >::Type, typename hidden::Traits< Rhs >::Type > > Selector
OperatorHelper< Lhs, Rhs, DifferenceWithOp< typename hidden::Traits< Lhs >::Type >, DifferenceOp< typename hidden::Traits< Rhs >::Type, typename hidden::Traits< Rhs >::Type > > Selector
OperatorHelper< Lhs, Rhs, DivisionWithOp< typename hidden::Traits< Lhs >::Type >, DivisionOp< typename hidden::Traits< Rhs >::Type, typename hidden::Traits< Rhs >::Type > > Selector
OperatorHelper< Lhs, Rhs, EqualWithOp< typename hidden::Traits< Lhs >::Type >, EqualOp< typename hidden::Traits< Rhs >::Type, typename hidden::Traits< Rhs >::Type > > Selector
OperatorHelper< Lhs, Rhs, GreaterThanOp< typename hidden::Traits< Lhs >::Type >, GreaterOp< typename hidden::Traits< Rhs >::Type, typename hidden::Traits< Rhs >::Type > > Selector
OperatorHelper< Lhs, Rhs, GeqThanOp< typename hidden::Traits< Lhs >::Type >, GeqOp< typename hidden::Traits< Rhs >::Type, typename hidden::Traits< Rhs >::Type > > Selector
OperatorHelper< Lhs, Rhs, LessThanOp< typename hidden::Traits< Lhs >::Type >, LessOp< typename hidden::Traits< Rhs >::Type, typename hidden::Traits< Rhs >::Type > > Selector
OperatorHelper< Lhs, Rhs, LeqThanOp< typename hidden::Traits< Lhs >::Type >, LeqOp< typename hidden::Traits< Rhs >::Type, typename hidden::Traits< Rhs >::Type > > Selector
OperatorHelper< Lhs, Rhs, LogicalAndWithOp< typename hidden::Traits< Lhs >::Type >, LogicalAndOp< typename hidden::Traits< Rhs >::Type, typename hidden::Traits< Rhs >::Type > > Selector
OperatorHelper< Lhs, Rhs, LogicalOrWithOp< typename hidden::Traits< Lhs >::Type >, LogicalOrOp< typename hidden::Traits< Rhs >::Type, typename hidden::Traits< Rhs >::Type > > Selector
OperatorHelper< Lhs, Rhs, MaxWithOp< typename hidden::Traits< Lhs >::Type >, MaxOp< typename hidden::Traits< Rhs >::Type, typename hidden::Traits< Rhs >::Type > > Selector
OperatorHelper< Lhs, Rhs, MinWithOp< typename hidden::Traits< Lhs >::Type >, MinOp< typename hidden::Traits< Rhs >::Type, typename hidden::Traits< Rhs >::Type > > Selector
OperatorHelper< Lhs, Rhs, ModuloWithOp< typename hidden::Traits< Lhs >::Type >, ModuloOp< typename hidden::Traits< Rhs >::Type, typename hidden::Traits< Rhs >::Type > > Selector
OperatorHelper< Lhs, Rhs, NotEqualWithOp< typename hidden::Traits< Lhs >::Type >, NotEqualOp< typename hidden::Traits< Rhs >::Type, typename hidden::Traits< Rhs >::Type > > Selector
OperatorHelper< Lhs, Rhs, ProductWithOp< typename hidden::Traits< Lhs >::Type >, ProductOp< typename hidden::Traits< Rhs >::Type, typename hidden::Traits< Rhs >::Type > > Selector
OperatorHelper< Lhs, Rhs, SumWithOp< typename hidden::Traits< Lhs >::Type >, SumOp< typename hidden::Traits< Rhs >::Type, typename hidden::Traits< Rhs >::Type > > Selector
helper defining the return type of the selector involving expressions of the form expr + number and e...