Numworks Epsilon  1.4.1
Graphing Calculator Operating System
real_part.cpp
Go to the documentation of this file.
1 #include <poincare/real_part.h>
2 #include <poincare/complex.h>
4 extern "C" {
5 #include <assert.h>
6 }
7 #include <cmath>
8 
9 namespace Poincare {
10 
12  return Type::RealPart;
13 }
14 
16  RealPart * a = new RealPart(m_operands, true);
17  return a;
18 }
19 
20 Expression * RealPart::shallowReduce(Context& context, AngleUnit angleUnit) {
21  Expression * e = Expression::shallowReduce(context, angleUnit);
22  if (e != this) {
23  return e;
24  }
25  Expression * op = editableOperand(0);
26 #if MATRIX_EXACT_REDUCING
27  if (op->type() == Type::Matrix) {
28  return SimplificationEngine::map(this, context, angleUnit);
29  }
30 #endif
31  if (op->type() == Type::Rational) {
32  return replaceWith(op, true);
33  }
34  return this;
35 }
36 
37 template<typename T>
38 Complex<T> RealPart::computeOnComplex(const Complex<T> c, AngleUnit angleUnit) {
39  return Complex<T>::Float(c.a());
40 }
41 
42 }
43 
44 
Expression * replaceWith(Expression *newOperand, bool deleteAfterReplace=true)
Definition: expression.cpp:85
Expression * clone() const override
Definition: real_part.cpp:15
c(generic_all_nodes)
Expression * editableOperand(int i)
Definition: expression.h:176
const Expression * m_operands[T]
friend class RealPart
Definition: expression.h:67
static Complex< T > Float(T x)
Definition: complex.cpp:23
Type type() const override
Definition: real_part.cpp:11