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
|
#include <poincare/hyperbolic_sine.h>
#include <poincare/complex.h>
#include <poincare/subtraction.h>
#include <poincare/power.h>
#include <poincare/fraction.h>
#include <poincare/opposite.h>
extern "C" {
#include <assert.h>
}
#include <cmath>
namespace Poincare {
HyperbolicSine::HyperbolicSine() :
Function("sinh")
{
}
Expression::Type HyperbolicSine::type() const {
return Type::HyperbolicSine;
}
Expression * HyperbolicSine::cloneWithDifferentOperands(Expression** newOperands,
int numberOfOperands, bool cloneOperands) const {
assert(newOperands != nullptr);
HyperbolicSine * hs = new HyperbolicSine();
hs->setArgument(newOperands, numberOfOperands, cloneOperands);
return hs;
}
template<typename T>
Complex<T> HyperbolicSine::compute(const Complex<T> c) {
if (c.b() == 0) {
return Complex<T>::Float(std::sinh(c.a()));
}
Complex<T> e = Complex<T>::Float(M_E);
Complex<T> exp1 = Power::compute(e, c);
Complex<T> exp2 = Power::compute(e, Complex<T>::Cartesian(-c.a(), -c.b()));
Complex<T> sub = Subtraction::compute(exp1, exp2);
return Fraction::compute(sub, Complex<T>::Float(2));
}
}
|