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