hyperbolic_tangent.h
1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef POINCARE_HYPERBOLIC_TANGENT_H
#define POINCARE_HYPERBOLIC_TANGENT_H
#include <poincare/layout_engine.h>
#include <poincare/static_hierarchy.h>
#include <poincare/approximation_engine.h>
namespace Poincare {
class HyperbolicTangent : public StaticHierarchy<1> {
using StaticHierarchy<1>::StaticHierarchy;
public:
Type type() const override;
Expression * clone() const override;
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, AngleUnit angleUnit);
private:
/* Layout */
ExpressionLayout * createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutEngine::createPrefixLayout(this, floatDisplayMode, numberOfSignificantDigits, name());
}
int writeTextInBuffer(char * buffer, int bufferSize, PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const override {
return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
}
const char * name() const { return "tanh"; }
/* Simplification */
Expression * shallowReduce(Context& context, AngleUnit angleUnit) override;
/* Evaluation */
Evaluation<float> * privateApproximate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override {
return ApproximationEngine::map<float>(this, context, angleUnit,computeOnComplex<float>);
}
Evaluation<double> * privateApproximate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override {
return ApproximationEngine::map<double>(this, context, angleUnit, computeOnComplex<double>);
}
};
}
#endif