- 3.0.2 core module.
CppADDoubleTrait.h
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4 **********************************************************************************************************************/
5 
6 #pragma once
7 
8 #include <cppad/cppad.hpp>
9 #include <cppad/example/cppad_eigen.hpp>
10 
11 namespace ct {
12 namespace core {
13 namespace internal {
14 
17 {
18  typedef CppAD::AD<double> Scalar;
19 
20  inline static Scalar sin(const Scalar& x) { return CppAD::sin(x); }
21  inline static Scalar cos(const Scalar& x) { return CppAD::cos(x); }
22  inline static Scalar tan(const Scalar& x) { return CppAD::tan(x); }
23  inline static Scalar sinh(const Scalar& x) { return CppAD::sinh(x); }
24  inline static Scalar cosh(const Scalar& x) { return CppAD::cosh(x); }
25  inline static Scalar tanh(const Scalar& x) { return CppAD::tanh(x); }
26  inline static Scalar exp(const Scalar& x) { return CppAD::exp(x); }
27  inline static Scalar fabs(const Scalar& x) { return CppAD::fabs(x); }
28  inline static Scalar sqrt(const Scalar& x) { return CppAD::sqrt(x); }
30  template <int Dims>
31  inline static Eigen::Matrix<Scalar, Dims, 1> solve(const Eigen::Matrix<Scalar, Dims, Dims>& A,
32  const Eigen::Matrix<Scalar, Dims, 1>& b)
33  {
34  return A.inverse() * b;
35  }
36 };
37 } // namespace internal
38 } // namespace core
39 } // namespace ct
static Scalar sinh(const Scalar &x)
Definition: CppADDoubleTrait.h:23
CppAD::AD< double > Scalar
Definition: CppADDoubleTrait.h:18
static Scalar tanh(const Scalar &x)
Definition: CppADDoubleTrait.h:25
static Scalar tan(const Scalar &x)
Definition: CppADDoubleTrait.h:22
static Scalar fabs(const Scalar &x)
Definition: CppADDoubleTrait.h:27
static Eigen::Matrix< Scalar, Dims, 1 > solve(const Eigen::Matrix< Scalar, Dims, Dims > &A, const Eigen::Matrix< Scalar, Dims, 1 > &b)
Solves a linear system of equations using Eigen&#39;s inverse functionality.
Definition: CppADDoubleTrait.h:31
static Scalar cosh(const Scalar &x)
Definition: CppADDoubleTrait.h:24
static Scalar sin(const Scalar &x)
Definition: CppADDoubleTrait.h:20
Trait defining basic math functions for CppAD Auto-Diff types.
Definition: CppADDoubleTrait.h:16
static Scalar cos(const Scalar &x)
Definition: CppADDoubleTrait.h:21
static Scalar exp(const Scalar &x)
Definition: CppADDoubleTrait.h:26
static Scalar sqrt(const Scalar &x)
Definition: CppADDoubleTrait.h:28