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
35
36
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
97 typedef typename If< bool(isUnary_), UnaryFunctor, BinaryFunctor>::Result Functor;
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>
123
126template<typename Lhs, typename Rhs>
136
139template<typename Lhs, typename Rhs>
149
152template<typename Lhs, typename Rhs>
162
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};
175
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};
188
191template<typename Lhs, typename Rhs>
201
204template<typename Lhs, typename Rhs>
214
217template<typename Lhs, typename Rhs>
227
230template<typename Lhs, typename Rhs>
240
243template<typename Lhs, typename Rhs>
253
256template<typename Lhs, typename Rhs>
266
269template<typename Lhs, typename Rhs>
279
282template<typename Lhs, typename Rhs>
292
295template<typename Lhs, typename Rhs>
305
308template<typename Lhs, typename Rhs>
318
321template<typename Lhs, typename Rhs>
331
334template<typename Lhs, typename Rhs>
344
345} // namespace hidden
346
347
348} // namespace STK
349
350#endif /* STK_BINARYSELECTOR_H */
Generic expression where a binary operator is applied to two expressions.
base class for template evaluation expressions and visitors.
Generic expression when unary operator is applied to an expression.
@ number_
(1,1) matrix/vector/array/expression (like a number)
the namespace Arrays contain the enum and utilities method used by the containers classes.
The hidden namespace enclose the classes and methods which are used internally by the STK++ classes.
The namespace STK is the main domain space of the Statistical ToolKit project.
Template functor which compute the bitwise and of two numbers.
Template functor to compute the bitwise and with a fixed value.
Template functor which compute the bitwise or of two numbers.
Template functor to compute the bitwise or with a fixed value.
Template functor which compute the bitwise xor of two numbers.
Template functor to compute the bitwise xor with a fixed value.
Template functor which compute the difference of two numbers.
Template functor to add a number to a fixed value.
Template functor which compute the division of two numbers.
Template functor to divide a number by a fixed value.
Template functor testing if a number is equal to an other number.
Template functor to test if a number is equal to a fixed value.
Template functor testing if a number is greater or equal than an other number.
Template functor to test if a number is greater or equal than a fixed value.
Template functor testing if a number is greater than an other number.
Template functor to test if a number is greater than a fixed value.
Template functor testing if a number is less or equal than an other number.
Template functor to test if a number is less or equal than a fixed value.
Template functor testing if a number is less than an other number.
Template functor to test if a number is less than a fixed value.
Template functor which compute the logical and of two numbers.
Template functor computing logical and with a fixed value.
Template functor which compute the logical or of two numbers.
Template functor computing logical and with a fixed value.
Template functor which compute the maximum of two numbers.
Template functor to compute the minimum with a fixed value.
Template functor which compute the minimum of two numbers.
Template functor to compute the minimum between a fixed value.
Template functor which compute the modulo of two numbers.
Template functor to compute the minimum with a fixed value.
Template functor testing if a number is not equal to an other number.
Template functor to test if a number is different than a fixed value.
Template functor which compute the product of two numbers.
Template functor computing the product of a number by a fixed value.
Template functor which compute the sum of two numbers.
Template functor to add a number to a fixed value.
Select a type at compile time.
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...