$darkmode
Eigen-unsupported  5.0.1-dev
StemFunction.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2010, 2013 Jitse Niesen <jitse@maths.leeds.ac.uk>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_STEM_FUNCTION
11 #define EIGEN_STEM_FUNCTION
12 
13 // IWYU pragma: private
14 #include "./InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
18 namespace internal {
19 
21 template <typename Scalar>
22 Scalar stem_function_exp(Scalar x, int) {
23  using std::exp;
24  return exp(x);
25 }
26 
28 template <typename Scalar>
29 Scalar stem_function_cos(Scalar x, int n) {
30  using std::cos;
31  using std::sin;
32  Scalar res;
33 
34  switch (n % 4) {
35  case 0:
36  res = std::cos(x);
37  break;
38  case 1:
39  res = -std::sin(x);
40  break;
41  case 2:
42  res = -std::cos(x);
43  break;
44  case 3:
45  res = std::sin(x);
46  break;
47  }
48  return res;
49 }
50 
52 template <typename Scalar>
53 Scalar stem_function_sin(Scalar x, int n) {
54  using std::cos;
55  using std::sin;
56  Scalar res;
57 
58  switch (n % 4) {
59  case 0:
60  res = std::sin(x);
61  break;
62  case 1:
63  res = std::cos(x);
64  break;
65  case 2:
66  res = -std::sin(x);
67  break;
68  case 3:
69  res = -std::cos(x);
70  break;
71  }
72  return res;
73 }
74 
76 template <typename Scalar>
77 Scalar stem_function_cosh(Scalar x, int n) {
78  using std::cosh;
79  using std::sinh;
80  Scalar res;
81 
82  switch (n % 2) {
83  case 0:
84  res = std::cosh(x);
85  break;
86  case 1:
87  res = std::sinh(x);
88  break;
89  }
90  return res;
91 }
92 
94 template <typename Scalar>
95 Scalar stem_function_sinh(Scalar x, int n) {
96  using std::cosh;
97  using std::sinh;
98  Scalar res;
99 
100  switch (n % 2) {
101  case 0:
102  res = std::sinh(x);
103  break;
104  case 1:
105  res = std::cosh(x);
106  break;
107  }
108  return res;
109 }
110 
111 } // end namespace internal
112 
113 } // end namespace Eigen
114 
115 #endif // EIGEN_STEM_FUNCTION
Namespace containing all symbols from the Eigen library.
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_exp_op< typename Derived::Scalar >, const Derived > exp(const Eigen::ArrayBase< Derived > &x)