Numworks Epsilon  1.4.1
Graphing Calculator Operating System
arc_sine.cpp
Go to the documentation of this file.
1 #include <poincare/arc_sine.h>
4 extern "C" {
5 #include <assert.h>
6 }
7 #include <cmath>
8 
9 namespace Poincare {
10 
12  return Type::ArcSine;
13 }
14 
16  ArcSine * a = new ArcSine(m_operands, true);
17  return a;
18 }
19 
20 Expression * ArcSine::shallowReduce(Context& context, AngleUnit angleUnit) {
21  Expression * e = Expression::shallowReduce(context, angleUnit);
22  if (e != this) {
23  return e;
24  }
25 #if MATRIX_EXACT_REDUCING
26  if (operand(0)->type() == Type::Matrix) {
27  return SimplificationEngine::map(this, context, angleUnit);
28  }
29 #endif
30  return Trigonometry::shallowReduceInverseFunction(this, context, angleUnit);
31 }
32 
33 template<typename T>
34 Complex<T> ArcSine::computeOnComplex(const Complex<T> c, AngleUnit angleUnit) {
35  assert(angleUnit != AngleUnit::Default);
36  if (c.b() != 0) {
37  return Complex<T>::Float(NAN);
38  }
39  T result = std::asin(c.a());
40  if (angleUnit == AngleUnit::Degree) {
41  return Complex<T>::Float(result*180/M_PI);
42  }
43  return Complex<T>::Float(result);
44 }
45 
46 }
#define NAN
Definition: math.h:30
#define assert(e)
Definition: assert.h:9
#define M_PI
Definition: math.h:17
friend class ArcSine
Definition: expression.h:32
#define T(x)
Definition: events.cpp:26
Type type() const override
Definition: arc_sine.cpp:11
#define asin(x)
Definition: math.h:165
c(generic_all_nodes)
const Expression * m_operands[T]
static Complex< T > Float(T x)
Definition: complex.cpp:23
static Expression * shallowReduceInverseFunction(Expression *e, Context &context, Expression::AngleUnit angleUnit)
const Expression * operand(int i) const
Definition: expression.cpp:78
Expression * clone() const override
Definition: arc_sine.cpp:15