ECF 1.5
Sin.h
1#ifndef Sin_h
2#define Sin_h
3#include "Function.h"
4#include <cmath>
5
6namespace cart
7{
8 template <class T>
9 class Sin : public Function
10 {
11 public:
12 Sin();
13 ~Sin();
14
15 void evaluate(voidP inputs, void* result);
16 };
17
18 typedef Sin<double> SinDouble;
19 typedef Sin<int> SinInt;
20
21 template <class T>
23 {
24 name_ = "sin";
25 numOfArgs_ = 1;
26 }
27
28 template <class T>
29 Sin<T>::~Sin()
30 {
31 }
32
33 template <class T>
34 void Sin<T>::evaluate(voidP inputs, void* result)
35 {
36 T& data = *(T*) result;
37 stringstream ss;
38 ss << *((string*) inputs.get());
39 vector<T> readInputs;
40 T input;
41 uint i = 0;
42 while (ss >> input)
43 {
44 readInputs.push_back(input);
45 ++i;
46 if (i == numOfArgs_)
47 {
48 break;
49 }
50 }
51
52 data = (T)sin((double)readInputs.at(0));
53 }
54
55}
56
57#endif /* Sin_h */
Definition: Sin.h:10
void evaluate(voidP inputs, void *result)
Definition: Sin.h:34