Blame view

build1/epsilon-master/poincare/src/equal.cpp 1.87 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  extern "C" {
  #include <assert.h>
  #include <stdlib.h>
  #include <math.h>
  #include <limits.h>
  }
  #include <poincare/equal.h>
  #include <ion.h>
  #include <poincare/rational.h>
  #include <poincare/addition.h>
  #include <poincare/division.h>
  #include <poincare/multiplication.h>
  #include <poincare/opposite.h>
  #include <poincare/power.h>
  #include <poincare/square_root.h>
  #include <poincare/subtraction.h>
  #include <poincare/symbol.h>
  #include "layout/char_layout.h"
  #include "layout/horizontal_layout.h"
  
  namespace Poincare {
  
  Expression::Type Equal::type() const {
    return Type::Equal;
  }
  
  Expression * Equal::clone() const {
    return new Equal(operands(), true);
  }
  
  int Equal::polynomialDegree(char symbolName) const {
    return -1;
  }
  
  Expression * Equal::standardEquation(Context & context, AngleUnit angleUnit) const {
    Expression * sub = new Subtraction(operand(0), operand(1), true);
    Reduce(&sub, context, angleUnit);
    return sub;
  }
  
  Expression * Equal::shallowReduce(Context& context, AngleUnit angleUnit) {
    Expression * e = Expression::shallowReduce(context, angleUnit);
    if (e != this) {
      return e;
    }
    if (operand(0)->isIdenticalTo(operand(1))) {
      return replaceWith(new Rational(1), true);
    }
    return this;
  }
  
  ExpressionLayout * Equal::createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const {
    HorizontalLayout * result = new HorizontalLayout();
    result->addOrMergeChildAtIndex(operand(0)->createLayout(floatDisplayMode, numberOfSignificantDigits), 0, false);
    result->addChildAtIndex(new CharLayout('='), result->numberOfChildren());
    result->addOrMergeChildAtIndex(operand(1)->createLayout(floatDisplayMode, numberOfSignificantDigits), result->numberOfChildren(), false);
    return result;
  }
  
  template<typename T>
  Evaluation<T> * Equal::templatedApproximate(Context& context, AngleUnit angleUnit) const {
    return new Complex<T>(Complex<T>::Undefined());
  }
  
  }