sincos.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2020 CNRS INRIA
3 // Copyright (c) 2015 Wandercraft, 86 rue de Paris 91400 Orsay, France.
4 //
5 
6 #ifndef __pinocchio_math_sincos_hpp__
7 #define __pinocchio_math_sincos_hpp__
8 
9 #include <cmath>
10 
11 namespace pinocchio
12 {
13  // Forward declaration
14  template<typename S1, typename S2 = S1, typename S3 = S1> struct SINCOSAlgo;
15 
25  template<typename S1, typename S2, typename S3>
26  void SINCOS(const S1 & a, S2 * sa, S3 * ca)
27  {
29  }
30 
32  template<typename S1, typename S2, typename S3>
33  struct SINCOSAlgo
34  {
35  static void run(const S1 & a, S2 * sa, S3 * ca)
36  {
37  using std::sin; using std::cos;
38  (*sa) = sin(a); (*ca) = cos(a);
39  }
40  };
41 
43  template<>
44  struct SINCOSAlgo<double>
45  {
46  static void run(const double & a, double * sa, double * ca)
47  {
48 #ifdef __linux__
49  sincos(a,sa,ca);
50 #elif __APPLE__
51  __sincos(a,sa,ca);
52 #else // if sincos specialization does not exist
53  (*sa) = std::sin(a); (*ca) = std::cos(a);
54 #endif
55  }
56  };
57 
59  template<>
60  struct SINCOSAlgo<float>
61  {
62  static void run(const float & a, float * sa, float * ca)
63  {
64 #ifdef __linux__
65  sincosf(a,sa,ca);
66 #elif __APPLE__
67  __sincosf(a,sa,ca);
68 #else // if sincosf specialization does not exist
69  (*sa) = std::sin(a); (*ca) = std::cos(a);
70 #endif
71  }
72  };
73 
75  template<>
76  struct SINCOSAlgo<long double>
77  {
78  static void run(const long double & a, long double * sa, long double * ca)
79  {
80 #ifdef __linux__
81  sincosl(a,sa,ca);
82 #else // if sincosl specialization does not exist
83  (*sa) = std::sin(a); (*ca) = std::cos(a);
84 #endif
85  }
86  };
87 
88 }
89 
90 #endif //#ifndef __pinocchio_math_sincos_hpp__
Generic evaluation of sin/cos functions.
Definition: sincos.hpp:14
static void run(const S1 &a, S2 *sa, S3 *ca)
Definition: sincos.hpp:35
static void run(const double &a, double *sa, double *ca)
Definition: sincos.hpp:46
void SINCOS(const S1 &a, S2 *sa, S3 *ca)
Computes sin/cos values of a given input scalar.
Definition: sincos.hpp:26
static void run(const long double &a, long double *sa, long double *ca)
Definition: sincos.hpp:78
Main pinocchio namespace.
Definition: timings.cpp:30
static void run(const float &a, float *sa, float *ca)
Definition: sincos.hpp:62


pinocchio
Author(s):
autogenerated on Tue Jun 1 2021 02:45:04