source: pacpussensors/trunk/Vislab/lib3dv/eigen/unsupported/Eigen/src/MatrixFunctions/StemFunction.h@ 136

Last change on this file since 136 was 136, checked in by ldecherf, 7 years ago

Doc

File size: 2.0 KB
Line 
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2010 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
13namespace Eigen {
14
15/** \ingroup MatrixFunctions_Module
16 * \brief Stem functions corresponding to standard mathematical functions.
17 */
18template <typename Scalar>
19class StdStemFunctions
20{
21 public:
22
23 /** \brief The exponential function (and its derivatives). */
24 static Scalar exp(Scalar x, int)
25 {
26 return std::exp(x);
27 }
28
29 /** \brief Cosine (and its derivatives). */
30 static Scalar cos(Scalar x, int n)
31 {
32 Scalar res;
33 switch (n % 4) {
34 case 0:
35 res = std::cos(x);
36 break;
37 case 1:
38 res = -std::sin(x);
39 break;
40 case 2:
41 res = -std::cos(x);
42 break;
43 case 3:
44 res = std::sin(x);
45 break;
46 }
47 return res;
48 }
49
50 /** \brief Sine (and its derivatives). */
51 static Scalar sin(Scalar x, int n)
52 {
53 Scalar res;
54 switch (n % 4) {
55 case 0:
56 res = std::sin(x);
57 break;
58 case 1:
59 res = std::cos(x);
60 break;
61 case 2:
62 res = -std::sin(x);
63 break;
64 case 3:
65 res = -std::cos(x);
66 break;
67 }
68 return res;
69 }
70
71 /** \brief Hyperbolic cosine (and its derivatives). */
72 static Scalar cosh(Scalar x, int n)
73 {
74 Scalar res;
75 switch (n % 2) {
76 case 0:
77 res = std::cosh(x);
78 break;
79 case 1:
80 res = std::sinh(x);
81 break;
82 }
83 return res;
84 }
85
86 /** \brief Hyperbolic sine (and its derivatives). */
87 static Scalar sinh(Scalar x, int n)
88 {
89 Scalar res;
90 switch (n % 2) {
91 case 0:
92 res = std::sinh(x);
93 break;
94 case 1:
95 res = std::cosh(x);
96 break;
97 }
98 return res;
99 }
100
101}; // end of class StdStemFunctions
102
103} // end namespace Eigen
104
105#endif // EIGEN_STEM_FUNCTION
Note: See TracBrowser for help on using the repository browser.