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 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 namespace Eigen {
14 
18 template <typename Scalar>
20 {
21  public:
22 
24  static Scalar exp(Scalar x, int)
25  {
26  return std::exp(x);
27  }
28 
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 
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 
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 
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
USING_NAMESPACE_ACADO IntermediateState sin(const Expression &arg)
static Scalar sin(Scalar x, int n)
Sine (and its derivatives).
Definition: StemFunction.h:51
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: matrix.hpp:471
IntermediateState cos(const Expression &arg)
static Scalar exp(Scalar x, int)
The exponential function (and its derivatives).
Definition: StemFunction.h:24
static Scalar cos(Scalar x, int n)
Cosine (and its derivatives).
Definition: StemFunction.h:30
Stem functions corresponding to standard mathematical functions.
Definition: StemFunction.h:19
static Scalar cosh(Scalar x, int n)
Hyperbolic cosine (and its derivatives).
Definition: StemFunction.h:72
static Scalar sinh(Scalar x, int n)
Hyperbolic sine (and its derivatives).
Definition: StemFunction.h:87
IntermediateState exp(const Expression &arg)


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:35:11