arc_sine.cpp
875 Bytes
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
#include <poincare/arc_sine.h>
extern "C" {
#include <assert.h>
}
#include <cmath>
namespace Poincare {
ArcSine::ArcSine() :
Function("asin")
{
}
Expression::Type ArcSine::type() const {
return Type::ArcSine;
}
Expression * ArcSine::cloneWithDifferentOperands(Expression** newOperands,
int numberOfOperands, bool cloneOperands) const {
assert(newOperands != nullptr);
ArcSine * s = new ArcSine();
s->setArgument(newOperands, numberOfOperands, cloneOperands);
return s;
}
template<typename T>
Complex<T> ArcSine::templatedComputeComplex(const Complex<T> c, AngleUnit angleUnit) const {
assert(angleUnit != AngleUnit::Default);
if (c.b() != 0) {
return Complex<T>::Float(NAN);
}
T result = std::asin(c.a());
if (angleUnit == AngleUnit::Degree) {
return Complex<T>::Float(result*180/M_PI);
}
return Complex<T>::Float(result);
}
}