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