Eigen-Contrib  5.0.1
 
Loading...
Searching...
No Matches
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// SPDX-License-Identifier: MPL-2.0
10
11#ifndef EIGEN_STEM_FUNCTION
12#define EIGEN_STEM_FUNCTION
13
14// IWYU pragma: private
15#include "./InternalHeaderCheck.h"
16
17namespace Eigen {
18
19namespace internal {
20
22template <typename Scalar>
23Scalar stem_function_exp(Scalar x, int) {
24 using std::exp;
25 return exp(x);
26}
27
29template <typename Scalar>
30Scalar stem_function_cos(Scalar x, int n) {
31 Scalar res;
32
33 switch (n % 4) {
34 case 0:
35 res = numext::cos(x);
36 break;
37 case 1:
38 res = -numext::sin(x);
39 break;
40 case 2:
41 res = -numext::cos(x);
42 break;
43 case 3:
44 res = numext::sin(x);
45 break;
46 }
47 return res;
48}
49
51template <typename Scalar>
52Scalar stem_function_sin(Scalar x, int n) {
53 Scalar res;
54
55 switch (n % 4) {
56 case 0:
57 res = numext::sin(x);
58 break;
59 case 1:
60 res = numext::cos(x);
61 break;
62 case 2:
63 res = -numext::sin(x);
64 break;
65 case 3:
66 res = -numext::cos(x);
67 break;
68 }
69 return res;
70}
71
73template <typename Scalar>
74Scalar stem_function_cosh(Scalar x, int n) {
75 Scalar res;
76
77 switch (n % 2) {
78 case 0:
79 res = numext::cosh(x);
80 break;
81 case 1:
82 res = numext::sinh(x);
83 break;
84 }
85 return res;
86}
87
89template <typename Scalar>
90Scalar stem_function_sinh(Scalar x, int n) {
91 Scalar res;
92
93 switch (n % 2) {
94 case 0:
95 res = numext::sinh(x);
96 break;
97 case 1:
98 res = numext::cosh(x);
99 break;
100 }
101 return res;
102}
103
104} // end namespace internal
105
106} // end namespace Eigen
107
108#endif // EIGEN_STEM_FUNCTION
Namespace containing all symbols from the Eigen library.