STK++ 0.9.13
STK_UnaryOperators.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: 17 oct. 2012
28 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 **/
30
35#ifndef STK_UNARYOPERATORS_H
36#define STK_UNARYOPERATORS_H
37
38namespace STK
39{
40// forward declaration
41template<typename UnaryOp, typename Lhs> class UnaryOperator;
42
43namespace hidden
44{
48template<typename UnaryOp, typename Lhs>
50{
51 enum
52 {
57 storage_ = Traits<Lhs>::storage_
58 };
61
62 typedef typename UnaryOp::result_type Type;
63 typedef typename UnaryOp::result_type TypeConst;
64};
65
66} // end namespace hidden
67
68// forward declaration
69template<typename UnaryOp, typename Lhs>
71
72
90template<typename UnaryOp, typename Lhs>
91class UnaryOperator: public ExprBase< UnaryOperator<UnaryOp, Lhs> >, public TRef<1>
92{
93 public:
97
98 enum
99 {
105 };
110
111 inline UnaryOperator( Lhs const& lhs, UnaryOp const& functor = UnaryOp())
113 {}
115 inline RowRange const& rowsImpl() const { return lhs_.rows();}
117 inline ColRange const& colsImpl() const { return lhs_.cols();}
118
120 inline Lhs const& lhs() const { return lhs_; }
122 inline UnaryOp const& functor() const { return functor_; }
123
128 inline TypeConst elt2Impl(int i, int j) const { return functor_(lhs_.elt(i, j));}
132 inline TypeConst elt1Impl(int i) const { return functor_(lhs_.elt(i));}
134 inline TypeConst elt0Impl() const { return functor_(lhs_.elt());}
135
136 protected:
137 Lhs const& lhs_;
139};
140
141} // namespace STK
142
143#endif /* STK_UNARYOPERATORS_H */
base class for template evaluation expressions and visitors.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Generic expression when unary operator is applied to an expression.
ColRange const & colsImpl() const
TRange< sizeCols_ > ColRange
Type of the Range for the columns.
ExprBase< UnaryOperator< UnaryOp, Lhs > > Base
TypeConst elt2Impl(int i, int j) const
UnaryOp const & functor() const
TypeConst elt1Impl(int i) const
UnaryOperator(Lhs const &lhs, UnaryOp const &functor=UnaryOp())
TypeConst elt0Impl() const
TRange< sizeRows_ > RowRange
Type of the Range for the rows.
RowRange const & rowsImpl() const
hidden::Traits< UnaryOperator< UnaryOp, Lhs > >::Type Type
Lhs const & lhs() const
hidden::Traits< UnaryOperator< UnaryOp, Lhs > >::TypeConst TypeConst
The namespace STK is the main domain space of the Statistical ToolKit project.
Base class for all referencing containers.
ColOperator< UnaryOperator< UnaryOp, Lhs > > Col
RowOperator< UnaryOperator< UnaryOp, Lhs > > Row