StemFunction.h
Go to the documentation of this file.
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>
23  using std::exp;
24  return exp(x);
25 }
26 
28 template <typename Scalar>
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>
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>
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>
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
AnnoyingScalar cos(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:136
AnnoyingScalar sin(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:137
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
SCALAR Scalar
Definition: bench_gemm.cpp:45
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 cosh(const bfloat16 &a)
Definition: BFloat16.h:638
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 exp(const bfloat16 &a)
Definition: BFloat16.h:615
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 sinh(const bfloat16 &a)
Definition: BFloat16.h:637
Scalar stem_function_exp(Scalar x, int)
The exponential function (and its derivatives).
Definition: StemFunction.h:22
Scalar stem_function_sin(Scalar x, int n)
Sine (and its derivatives).
Definition: StemFunction.h:53
Scalar stem_function_cos(Scalar x, int n)
Cosine (and its derivatives).
Definition: StemFunction.h:29
Scalar stem_function_cosh(Scalar x, int n)
Hyperbolic cosine (and its derivatives).
Definition: StemFunction.h:77
Scalar stem_function_sinh(Scalar x, int n)
Hyperbolic sine (and its derivatives).
Definition: StemFunction.h:95
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
Definition: Eigen_Colamd.h:49
list x
Definition: plotDoE.py:28