LoAdSG
funktorExample.h
1#ifndef FUNKTOREXAMPLE_SG_H
2#define FUNKTOREXAMPLE_SG_H
3
4#include "extempAlg.h"
5#include "funktor.h"
6#include <cmath>
7
8
9
10
11class SinFunctor {
12public:
13 SinFunctor() = default;
14
15 static double evaluate(double x) {
16 return sin(x);
17 }
18};
19
20
21class Atan2Functor {
22public:
23 Atan2Functor() = default;
24
25 static double evaluate(double y, double x) {
26 return atan2(y, x);
27 }
28};
29
30class CosFunctor {
31public:
32 CosFunctor() = default;
33
34 static double evaluate(double x) {
35 return cos(x);
36 }
37};
38
39
40class SinHFunctor {
41public:
42 SinHFunctor() = default;
43
44 static double evaluate(double x) {
45 return sinh(x);
46 }
47};
48
49
50class LogFunctor {
51public:
52 LogFunctor() = default;
53
54 static double evaluate(double x) {
55 return log(x);
56 }
57};
58
59class CosHFunctor {
60public:
61 CosHFunctor() = default;
62
63 static double evaluate(double x) {
64 return cosh(x);
65 }
66};
67
68
69class ExpFunctor {
70public:
71 ExpFunctor() = default;
72
73 static double evaluate(double x) {
74 //return exp(x);
75 return exp(x);
76
77 }
78};
79
80
81class SqrtFunctor {
82public:
83 SqrtFunctor() = default;
84
85 static double evaluate(double x) {
86 return sqrt(x);
87 }
88};
89
90class ArcTanFunctor {
91public:
92 ArcTanFunctor() = default;
93
94 static double evaluate(double x) {
95
96 return atan(x);
97 }
98};
99
100class PowerFunctor {
101public:
102 PowerFunctor() {
103 a = 1.0;
104 }
105
106 double evaluate(double x) {
107 return pow(x, a);
108 }
109
110 double a;
111};
112
113
114
115
116class CountFunctor {
117public:
118 CountFunctor() { count = 0; }
119
120 double evaluate(double x) {
121 count++;
122 return (double) count;
123 }
124
125 inline void resetCount() { count = 0; }
126
127private:
128 unsigned long count;
129};
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150#endif