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 #include "./InternalHeaderCheck.h"
14 
15 namespace Eigen {
16 
17 namespace internal {
18 
20 template <typename Scalar>
21 Scalar stem_function_exp(Scalar x, int)
22 {
23  using std::exp;
24  return exp(x);
25 }
26 
28 template <typename Scalar>
29 Scalar stem_function_cos(Scalar x, int n)
30 {
31  using std::cos;
32  using std::sin;
33  Scalar res;
34 
35  switch (n % 4) {
36  case 0:
37  res = std::cos(x);
38  break;
39  case 1:
40  res = -std::sin(x);
41  break;
42  case 2:
43  res = -std::cos(x);
44  break;
45  case 3:
46  res = std::sin(x);
47  break;
48  }
49  return res;
50 }
51 
53 template <typename Scalar>
54 Scalar stem_function_sin(Scalar x, int n)
55 {
56  using std::cos;
57  using std::sin;
58  Scalar res;
59 
60  switch (n % 4) {
61  case 0:
62  res = std::sin(x);
63  break;
64  case 1:
65  res = std::cos(x);
66  break;
67  case 2:
68  res = -std::sin(x);
69  break;
70  case 3:
71  res = -std::cos(x);
72  break;
73  }
74  return res;
75 }
76 
78 template <typename Scalar>
79 Scalar stem_function_cosh(Scalar x, int n)
80 {
81  using std::cosh;
82  using std::sinh;
83  Scalar res;
84 
85  switch (n % 2) {
86  case 0:
87  res = std::cosh(x);
88  break;
89  case 1:
90  res = std::sinh(x);
91  break;
92  }
93  return res;
94 }
95 
97 template <typename Scalar>
98 Scalar stem_function_sinh(Scalar x, int n)
99 {
100  using std::cosh;
101  using std::sinh;
102  Scalar res;
103 
104  switch (n % 2) {
105  case 0:
106  res = std::sinh(x);
107  break;
108  case 1:
109  res = std::cosh(x);
110  break;
111  }
112  return res;
113 }
114 
115 } // end namespace internal
116 
117 } // end namespace Eigen
118 
119 #endif // EIGEN_STEM_FUNCTION
int n
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Scalar stem_function_exp(Scalar x, int)
The exponential function (and its derivatives).
Definition: StemFunction.h:21
Scalar stem_function_sin(Scalar x, int n)
Sine (and its derivatives).
Definition: StemFunction.h:54
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:79
Scalar stem_function_sinh(Scalar x, int n)
Hyperbolic sine (and its derivatives).
Definition: StemFunction.h:98
: TensorContractionSycl.h, provides various tensor contraction kernel for SYCL backend
Eigen::AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Eigen::internal::remove_all_t< DerType >, typename Eigen::internal::traits< Eigen::internal::remove_all_t< DerType >>::Scalar, product) > sinh(const Eigen::AutoDiffScalar< DerType > &x)
Eigen::AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Eigen::internal::remove_all_t< DerType >, typename Eigen::internal::traits< Eigen::internal::remove_all_t< DerType >>::Scalar, product) > cos(const Eigen::AutoDiffScalar< DerType > &x)
Eigen::AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Eigen::internal::remove_all_t< DerType >, typename Eigen::internal::traits< Eigen::internal::remove_all_t< DerType >>::Scalar, product) > exp(const Eigen::AutoDiffScalar< DerType > &x)
Eigen::AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Eigen::internal::remove_all_t< DerType >, typename Eigen::internal::traits< Eigen::internal::remove_all_t< DerType >>::Scalar, product) > sin(const Eigen::AutoDiffScalar< DerType > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_exp_op< typename Derived::Scalar >, const Derived > exp(const Eigen::ArrayBase< Derived > &x)
Eigen::AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Eigen::internal::remove_all_t< DerType >, typename Eigen::internal::traits< Eigen::internal::remove_all_t< DerType >>::Scalar, product) > cosh(const Eigen::AutoDiffScalar< DerType > &x)