ECF 1.5
Ln.h
1#ifndef ECF_CARTESIAN_LN_H
2#define ECF_CARTESIAN_LN_H
3#include "Function.h"
4namespace cartesian{
5 template <typename Container, typename Result>
6 class Nlog : public Function<Container,Result> {
7 public:
8 Nlog();
9 ~Nlog(){};
10 void evaluate(Container& container, Result& result);
11 };
12
13 template <typename Container, typename Result>
15 {
16 this->name_ = "ln";
17 this->numOfArgs_ = 1;
18 }
19
20 template <typename Container, typename Result>
21 void Nlog<Container,Result>::evaluate(Container& container, Result& result)
22 {
23 typename Container::iterator it = container.begin();
24 if(std::isnan(*it) || std::isinf(*it) || *it == 0) {
25 result = 1.0;
26 }
27 else if(*it < 0.0) {
28 result = std::log(std::abs(*it));
29 }
30 else {
31 result = std::log(*it);
32 }
33 }
34}
35#endif //ECF_CARTESIAN_LN_H
void evaluate(Container &container, Result &result)
Definition: Ln.h:21