Numworks Epsilon  1.4.1
Graphing Calculator Operating System
tangent.cpp
Go to the documentation of this file.
1 #include <poincare/tangent.h>
2 #include <poincare/complex.h>
3 #include <poincare/sine.h>
4 #include <poincare/cosine.h>
5 #include <poincare/division.h>
10 extern "C" {
11 #include <assert.h>
12 }
13 #include <cmath>
14 
15 namespace Poincare {
16 
19 }
20 
22  Tangent * a = new Tangent(m_operands, true);
23  return a;
24 }
25 
26 float Tangent::characteristicXRange(Context & context, AngleUnit angleUnit) const {
27  return Trigonometry::characteristicXRange(this, context, angleUnit);
28 }
29 
30 Expression * Tangent::shallowReduce(Context& context, AngleUnit angleUnit) {
31  Expression * e = Expression::shallowReduce(context, angleUnit);
32  if (e != this) {
33  return e;
34  }
35 #if MATRIX_EXACT_REDUCING
36  Expression * op = editableOperand(0);
37  if (op->type() == Type::Matrix) {
38  return SimplificationEngine::map(this, context, angleUnit);
39  }
40 #endif
41  Expression * newExpression = Trigonometry::shallowReduceDirectFunction(this, context, angleUnit);
42  if (newExpression->type() == Type::Tangent) {
43  const Expression * op[1] = {newExpression->operand(0)};
44  Sine * s = new Sine(op, true);
45  Cosine * c = new Cosine(op, true);
46  Division * d = new Division(s, c, false);
47  newExpression = newExpression->replaceWith(d, true);
48  return newExpression->shallowReduce(context, angleUnit);
49  }
50  return newExpression;
51 }
52 
53 template<typename T>
54 Complex<T> Tangent::computeOnComplex(const Complex<T> c, AngleUnit angleUnit) {
55  Complex<T> result = Division::compute(Sine::computeOnComplex(c, angleUnit), Cosine::computeOnComplex(c, angleUnit));
56  if (!std::isnan(result.a()) && !std::isnan(result.b())) {
57  return result;
58  }
61 }
62 
63 }
static float characteristicXRange(const Expression *e, Context &context, Expression::AngleUnit angleUnit)
friend class Division
Definition: expression.h:25
static Complex< T > Cartesian(T a, T b)
Definition: complex.cpp:28
friend class Sine
Definition: expression.h:27
friend class Tangent
Definition: expression.h:29
Type type() const override
Definition: tangent.cpp:17
c(generic_all_nodes)
Expression * editableOperand(int i)
Definition: expression.h:176
static Complex< T > compute(const Complex< T > c, const Complex< T > d)
Definition: division.cpp:52
const Expression * m_operands[T]
#define tanh(x)
Definition: math.h:198
#define isnan(x)
Definition: math.h:43
static Expression * shallowReduceDirectFunction(Expression *e, Context &context, Expression::AngleUnit angleUnit)
static Complex< T > compute(const Complex< T > c, const Complex< T > d)
Expression * clone() const override
Definition: tangent.cpp:21
static Complex< T > computeOnComplex(const Complex< T > c, AngleUnit angleUnit=AngleUnit::Radian)
Definition: cosine.cpp:44
static Complex< T > computeOnComplex(const Complex< T > c, AngleUnit angleUnit)
float characteristicXRange(Context &context, AngleUnit angleUnit=AngleUnit::Default) const override
Definition: tangent.cpp:26
friend class Cosine
Definition: expression.h:28
static Complex< T > computeOnComplex(const Complex< T > c, AngleUnit angleUnit=AngleUnit::Radian)
Definition: sine.cpp:44