ECF 1.5
Div.h
1#ifndef ECF_CARTESIAN_DIV_H
2#define ECF_CARTESIAN_DIV_H
3#include "Function.h"
4namespace cartesian{
5 const double DIVISION_THRESHOLD = 10e-7;
6 template <typename Container, typename Result>
7 class Div : public Function<Container,Result> {
8 public:
9 Div();
10 ~Div(){};
11 void evaluate(Container& container, Result& result);
12 };
13
14 template <typename Container, typename Result>
16 {
17 this->name_ = "/";
18 this->numOfArgs_ = 2;
19 }
20
21 template <typename Container, typename Result>
22 void Div<Container,Result>::evaluate(Container& container, Result& result)
23 {
24 result = *(container.begin());
25 for(typename Container::iterator it = container.begin() + 1; it != container.begin() + this->numOfArgs_; it++) {
26 if(*it <= DIVISION_THRESHOLD) {
27 continue;
28 }
29 result /= *it;
30 }
31 }
32}
33#endif //ECF_CARTESIAN_DIV_H
void evaluate(Container &container, Result &result)
Definition: Div.h:22