sine.h
1.73 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
39
40
41
#ifndef POINCARE_SINE_H
#define POINCARE_SINE_H
#include <poincare/layout_engine.h>
#include <poincare/static_hierarchy.h>
#include <poincare/approximation_engine.h>
#include <poincare/trigonometry.h>
namespace Poincare {
class Sine : public StaticHierarchy<1> {
using StaticHierarchy<1>::StaticHierarchy;
friend class Tangent;
float characteristicXRange(Context & context, AngleUnit angleUnit) const override;
public:
Type type() const override;
Expression * clone() const override;
template<typename T> static std::complex<T> computeOnComplex(const std::complex<T> c, AngleUnit angleUnit = AngleUnit::Radian);
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 "sin"; }
/* Simplication */
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