- 3.0.2 core module.
DoubleTrait.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 namespace ct {
9 namespace core {
10 namespace internal {
11 
14 {
15  typedef double Scalar;
16 
17  inline static Scalar sin(const Scalar& x) { return std::sin(x); }
18  inline static Scalar cos(const Scalar& x) { return std::cos(x); }
19  inline static Scalar tan(const Scalar& x) { return std::tan(x); }
20  inline static Scalar sinh(const Scalar& x) { return std::sinh(x); }
21  inline static Scalar cosh(const Scalar& x) { return std::cosh(x); }
22  inline static Scalar tanh(const Scalar& x) { return std::tanh(x); }
23  inline static Scalar exp(const Scalar& x) { return std::exp(x); }
24  inline static Scalar fabs(const Scalar& x) { return std::fabs(x); }
25  inline static Scalar sqrt(const Scalar& x) { return std::sqrt(x); }
27  template <int Rows, int Cols>
28  inline static Eigen::Matrix<Scalar, Cols, 1> solve(const Eigen::Matrix<Scalar, Rows, Cols>& A,
29  const Eigen::Matrix<Scalar, Rows, 1>& b)
30  {
31  return A.inverse() * b;
32  }
33 };
34 } // namespace internal
35 } // namespace core
36 } // namespace ct
static Scalar tanh(const Scalar &x)
Definition: DoubleTrait.h:22
double Scalar
Definition: DoubleTrait.h:15
static Scalar tan(const Scalar &x)
Definition: DoubleTrait.h:19
static Scalar cosh(const Scalar &x)
Definition: DoubleTrait.h:21
static Eigen::Matrix< Scalar, Cols, 1 > solve(const Eigen::Matrix< Scalar, Rows, Cols > &A, const Eigen::Matrix< Scalar, Rows, 1 > &b)
Solves a linear system of equations using Eigen&#39;s inverse functionality.
Definition: DoubleTrait.h:28
static Scalar sin(const Scalar &x)
Definition: DoubleTrait.h:17
static Scalar cos(const Scalar &x)
Definition: DoubleTrait.h:18
static Scalar fabs(const Scalar &x)
Definition: DoubleTrait.h:24
static Scalar sinh(const Scalar &x)
Definition: DoubleTrait.h:20
Trait defining basic math functions for double types.
Definition: DoubleTrait.h:13
static Scalar exp(const Scalar &x)
Definition: DoubleTrait.h:23
static Scalar sqrt(const Scalar &x)
Definition: DoubleTrait.h:25