LoAdSG
funktor.h
1#ifndef FUNKTOR_SG_H
2#define FUNKTOR_SG_H
3
4/*#include "extempAlg.h"
5#include <math.h> */
6
14template <class A, class Func>
15class Exp_Functor : public ExprSparseG<Exp_Functor<A, Func> > {
16 const A &a_;
17 Func *functor_;
18public:
19 inline Exp_Functor(const A &a, Func *functor)
20 : a_(a), functor_(functor) {}
21
22 inline double getValue(int i, const IndexDimension &I) const {
23 return functor_->evaluate(a_.getValue(i, I));
24 };
25
26
27 ExpressionDescription getDescription() const { return a_.getDescription(); }
28};
29
30template<class A, class B, class Func>
31class Atan2_Functor : public ExprSparseG<Atan2_Functor<A, B, Func> > {
32 const A &a_;
33 const B &b_;
34 Func *functor_;
35public:
36 inline Atan2_Functor(const A &a, const B &b, Func *functor)
37 : a_(a), b_(b), functor_(functor) {}
38
39 inline double getValue(int i, const IndexDimension &I) const {
40 return functor_->evaluate(a_.getValue(i, I), b_.getValue(i, I));
41 };
42
43
44
45
46 ExpressionDescription getDescription() const { return a_.getDescription(); }
47};
48
49
50
51
52
53
54#include <cmath>
55
56
57
58template<class Func>
59class Functor {
60public:
61 Functor(Func &functor) : functor_(&functor) {};
62
63 template<class A>
65 operator()(const ExprSparseG<A> &a) const {
66 return Exp_Functor<A, Func>(a, functor_);
67 }
68
69 template<class A, class B>
70 inline Atan2_Functor<A, B, Func>
71 operator()(const ExprSparseG<A> &a, const ExprSparseG<B> &b) const {
72 return Atan2_Functor<A, B, Func>(a, b, functor_);
73 }
74
75
76
77private:
78 Func *functor_;
79};
80
81
82
83/* @} */
84
85
86#endif
Definition funktor.h:15