ECF 1.5
Cos.h
1#ifndef Cos_h
2#define Cos_h
3#include "Function.h"
4#include <cmath>
5
6namespace cart
7{
8 template <class T>
9 class Cos : public Function
10 {
11 public:
12 Cos();
13 ~Cos();
14
15 void evaluate(voidP inputs, void* result);
16 };
17
18 typedef Cos<double> CosDouble;
19 typedef Cos<int> CosInt;
20
21 template <class T>
23 {
24 name_ = "cos";
25 numOfArgs_ = 1;
26 }
27
28 template <class T>
29 Cos<T>::~Cos()
30 {
31 }
32
33 template <class T>
34 void Cos<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)cos((double)readInputs.at(0));
53 }
54
55}
56
57#endif /* Cos_h */
Definition: Cos.h:10
void evaluate(voidP inputs, void *result)
Definition: Cos.h:34