ANIMA  4.0
animaHyperbolicFunctions.hxx
Go to the documentation of this file.
1 #pragma once
2 
4 
5 namespace anima
6 {
7 
8 template <class T> double ShOverId(const T &x)
9 {
10  double resVal = x;
11 
12  if (resVal < 1e-4)
13  resVal = 1.0 + resVal * resVal / 6.0;
14  else
15  resVal = std::sinh(resVal) / resVal;
16 
17  return resVal;
18 }
19 
20 template <class ScalarType> std::complex<double> ComplexShRatio(const ScalarType &k, const ScalarType &alpha, const ScalarType &beta)
21 {
22  double ss = alpha * alpha + beta * beta;
23 
24  double constant = k * std::exp(alpha - k) / ss / (1 - std::exp(- 2.0 * k));
25 
26  double realVal = constant * (alpha * (1.0 - std::exp(- 2.0 * alpha)) * std::cos(beta) + beta * (1.0 + std::exp(- 2.0 * alpha)) * std::sin(beta));
27 
28  double imagVal = constant * (alpha * (1.0 + std::exp(- 2.0 * alpha)) * std::sin(beta) - beta * (1.0 - std::exp(- 2.0 * alpha)) * std::cos(beta));
29 
30  return std::complex<double>(realVal, imagVal);
31 }
32 
33 template <class T1, class T2, class T3> double ShRatio(const T1 &k, const T2 &alpha, const T3 &beta)
34 {
35  double ss = alpha * alpha + beta * beta;
36 
37  double resVal = k * exp(alpha - k) * (alpha * (1.0 - exp(- 2.0 * alpha)) * cos(beta) + beta * (1.0 + exp(- 2.0 * alpha)) * sin(beta)) / ss / (1 - exp(- 2.0 * k));
38 
39  return resVal;
40 }
41 
42 template <class T> double xi(const T &k)
43 {
44  double resVal = k * k;
45 
46  if (k < 1e-4)
47  resVal = 1.0 / 3.0 - resVal / 45;
48  else
49  resVal = 1.0 / (k * tanh(k)) - 1.0 / resVal;
50 
51  return resVal;
52 }
53 
54 template <class T> double jtwo(const T &k)
55 {
56  double jtwoVal = k * k;
57 
58  if (k < 1e-4)
59  jtwoVal = 1.0 / 3.0 + 2.0 * k * k / 45.0;
60  else
61  jtwoVal = 1.0 - 2.0 * (1.0 / (k * tanh(k)) - 1.0 / jtwoVal);
62 
63  return jtwoVal;
64 }
65 
66 template <class T> double jfour(const T &k)
67 {
68  double jfourVal = k * k;
69 
70  if (k < 1e-3)
71  jfourVal = 1.0 / 5.0 + 4.0 * k * k / 45.0;
72  else
73  jfourVal = 1.0 - 4.0 * (1.0 / (k * tanh(k)) - 3.0 * (1.0 - 2.0 * (1.0 / (k * tanh(k)) - 1.0 / jfourVal)) / jfourVal);
74 
75  return jfourVal;
76 }
77 
78 } // end of namespace anima
79 
80 
std::complex< double > ComplexShRatio(const ScalarType &k, const ScalarType &alpha, const ScalarType &beta)
double ShOverId(const T &x)
double xi(const T &k)
double ShRatio(const T1 &k, const T2 &alpha, const T3 &beta)
double jtwo(const T &k)
double jfour(const T &k)