Blame view

Giac_maj/epsilon-giac/poincare/src/absolute_value.cpp 1.06 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
  #include <poincare/absolute_value.h>
  #include <poincare/complex.h>
  #include "layout/absolute_value_layout.h"
  
  extern "C" {
  #include <assert.h>
  }
  #include <cmath>
  
  namespace Poincare {
  
  AbsoluteValue::AbsoluteValue() :
    Function("abs")
  {
  }
  
  Expression::Type AbsoluteValue::type() const {
    return Type::AbsoluteValue;
  }
  
  Expression * AbsoluteValue::cloneWithDifferentOperands(Expression** newOperands,
          int numberOfOperands, bool cloneOperands) const {
    assert(newOperands != nullptr);
    AbsoluteValue * a = new AbsoluteValue();
    a->setArgument(newOperands, numberOfOperands, cloneOperands);
    return a;
  }
  
  template<typename T>
  Complex<T> AbsoluteValue::templatedComputeComplex(const Complex<T> c) const {
    return Complex<T>::Float(c.r());
  }
  
  ExpressionLayout * AbsoluteValue::privateCreateLayout(FloatDisplayMode floatDisplayMode, ComplexFormat complexFormat) const {
    assert(floatDisplayMode != FloatDisplayMode::Default);
    assert(complexFormat != ComplexFormat::Default);
    return new AbsoluteValueLayout(m_args[0]->createLayout(floatDisplayMode, complexFormat));
  }
  
  }