WPILibC++ 2024.3.2
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
15
16namespace Eigen {
17
18namespace internal {
19
20/** \brief The exponential function (and its derivatives). */
21template <typename Scalar>
22Scalar stem_function_exp(Scalar x, int) {
23 using std::exp;
24 return exp(x);
25}
26
27/** \brief Cosine (and its derivatives). */
28template <typename Scalar>
29Scalar 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
51/** \brief Sine (and its derivatives). */
52template <typename Scalar>
53Scalar 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
75/** \brief Hyperbolic cosine (and its derivatives). */
76template <typename Scalar>
77Scalar 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
93/** \brief Hyperbolic sine (and its derivatives). */
94template <typename Scalar>
95Scalar 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
dimensionless::scalar_t sinh(const AngleUnit angle) noexcept
Compute hyperbolic sine.
Definition: math.h:226
dimensionless::scalar_t cosh(const AngleUnit angle) noexcept
Compute hyperbolic cosine.
Definition: math.h:206
dimensionless::scalar_t cos(const AngleUnit angle) noexcept
Compute cosine.
Definition: math.h:61
dimensionless::scalar_t sin(const AngleUnit angle) noexcept
Compute sine.
Definition: math.h:81
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
Definition: MatrixSquareRoot.h:16