Loading...
Searching...
No Matches
cast.hpp
Go to the documentation of this file.
1/*
2 * Copyright 2021-2022 INRIA
3 */
4
5#ifndef __pycppad_cast_hpp__
6#define __pycppad_cast_hpp__
7
8#include "pycppad/fwd.hpp"
9
10#include <eigenpy/user-type.hpp>
11
12namespace pycppad
13{
14 namespace internal
15 {
16
17 template<typename From, typename To>
18 struct Cast
19 {
20 static To run(const From & from)
21 {
22 return static_cast<To>(from);
23 }
24 };
25
26 template<typename Scalar>
28 {
29 static Scalar get(const ::CppAD::AD<Scalar> & v)
30 {
31 return ::CppAD::Value<Scalar>(v);
32 }
33 };
34
35 template<typename Scalar, typename To>
36 struct Cast<::CppAD::AD<Scalar>,To>
37 {
38 typedef ::CppAD::AD<Scalar> From;
39 static To run(const From & from)
40 {
41 return static_cast<To>(CppADValue<Scalar>::get(from));
42 }
43 };
44 } // namespace internal
45} // namespace pycppad
46
47namespace eigenpy {
48
49template <typename Scalar, typename To>
50struct cast<::CppAD::AD<Scalar>, To>
51{
52 typedef ::CppAD::AD<Scalar> From;
53 static To run(const From & from) {
54 return ::pycppad::internal::Cast<From, To>::run(from);
55 }
56};
57
58template <typename From, typename Scalar>
59struct cast<From,::CppAD::AD<Scalar>>
60{
61 typedef ::CppAD::AD<Scalar> To;
62 static To run(const From & from) {
63 return To(static_cast<Scalar>(from));
64 }
65};
66
67} // namespace eigenpy
68
69#endif //#ifndef __pycppad_cast_hpp__
Definition cast.hpp:47
Definition ad.hpp:15
::CppAD::AD< Scalar > To
Definition cast.hpp:61
static To run(const From &from)
Definition cast.hpp:62
static To run(const From &from)
Definition cast.hpp:53
::CppAD::AD< Scalar > From
Definition cast.hpp:52
static To run(const From &from)
Definition cast.hpp:39
::CppAD::AD< Scalar > From
Definition cast.hpp:38
Definition cast.hpp:19
static To run(const From &from)
Definition cast.hpp:20
Definition cast.hpp:28
static Scalar get(const ::CppAD::AD< Scalar > &v)
Definition cast.hpp:29