Numworks Epsilon  1.4.1
Graphing Calculator Operating System
naperian_logarithm.cpp
Go to the documentation of this file.
2 #include <poincare/symbol.h>
3 #include <poincare/logarithm.h>
5 extern "C" {
6 #include <assert.h>
7 #include <stdlib.h>
8 }
9 #include <ion.h>
10 #include <cmath>
13 #include "layout/string_layout.h"
14 
15 namespace Poincare {
16 
19 }
20 
23  return a;
24 }
25 
26 Expression * NaperianLogarithm::shallowReduce(Context& context, AngleUnit angleUnit) {
27  Expression * e = Expression::shallowReduce(context, angleUnit);
28  if (e != this) {
29  return e;
30  }
31 #if MATRIX_EXACT_REDUCING
32  if (operand(0)->type() == Type::Matrix) {
33  return SimplificationEngine::map(this, context, angleUnit);
34  }
35 #endif
36  const Expression * logOperands[2] = {operand(0)->clone(), new Symbol(Ion::Charset::Exponential)};
37  Logarithm * l = new Logarithm(logOperands, 2, false);
38  replaceWith(l, true);
39  return l->shallowReduce(context, angleUnit);
40 }
41 
42 template<typename T>
43 Complex<T> NaperianLogarithm::computeOnComplex(const Complex<T> c, AngleUnit angleUnit) {
44  if (c.b() != 0) {
45  return Complex<T>::Float(NAN);
46  }
47  return Complex<T>::Float(std::log(c.a()));
48 }
49 
50 }
#define NAN
Definition: math.h:30
friend class Logarithm
Definition: expression.h:55
Expression * replaceWith(Expression *newOperand, bool deleteAfterReplace=true)
Definition: expression.cpp:85
friend class Symbol
Definition: expression.h:72
virtual Expression * clone() const =0
c(generic_all_nodes)
friend class NaperianLogarithm
Definition: expression.h:60
#define log(x)
Definition: math.h:184
Expression * clone() const override
const Expression * m_operands[T]
static Complex< T > Float(T x)
Definition: complex.cpp:23
const Expression * operand(int i) const
Definition: expression.cpp:78