10 #ifndef EIGEN_AUTODIFF_SCALAR_H 11 #define EIGEN_AUTODIFF_SCALAR_H 17 template<
typename A,
typename B>
23 template<
typename A,
typename B>
35 template<
typename NewDerType>
66 template<
typename DerivativeType>
69 <DerivativeType, !internal::is_same<typename internal::traits<typename internal::remove_all<DerivativeType>::type>::Scalar,
70 typename NumTraits<typename internal::traits<typename internal::remove_all<DerivativeType>::type>::Scalar>::Real>::value>
80 using Base::operator+;
81 using Base::operator*;
89 : m_value(value), m_derivatives(DerType::Zero(nbDer))
91 m_derivatives.coeffRef(derNumber) =
Scalar(1);
99 if(m_derivatives.size()>0)
100 m_derivatives.setZero();
105 : m_value(value), m_derivatives(der)
108 template<
typename OtherDerType>
110 #ifndef EIGEN_PARSED_BY_DOXYGEN
121 return s << a.
value();
125 : m_value(other.
value()), m_derivatives(other.derivatives())
128 template<
typename OtherDerType>
131 m_value = other.
value();
138 m_value = other.
value();
146 if(m_derivatives.size()>0)
147 m_derivatives.setZero();
154 inline const Scalar&
value()
const {
return m_value; }
155 inline Scalar&
value() {
return m_value; }
157 inline const DerType&
derivatives()
const {
return m_derivatives; }
174 template<
typename OtherDerType>
inline bool operator< (const AutoDiffScalar<OtherDerType>&
b)
const {
return m_value <
b.value(); }
175 template<
typename OtherDerType>
inline bool operator<=(const AutoDiffScalar<OtherDerType>&
b)
const {
return m_value <=
b.value(); }
207 template<
typename OtherDerType>
213 m_value + other.
value(),
217 template<
typename OtherDerType>
221 (*this) = (*this) +
other;
233 return AutoDiffScalar<CwiseUnaryOp<internal::scalar_opposite_op<Scalar>,
const DerType> >
243 template<
typename OtherDerType>
249 m_value - other.
value(),
253 template<
typename OtherDerType>
257 *
this = *
this -
other;
261 inline const AutoDiffScalar<CwiseUnaryOp<internal::scalar_opposite_op<Scalar>,
const DerType> >
264 return AutoDiffScalar<CwiseUnaryOp<internal::scalar_opposite_op<Scalar>,
const DerType> >(
325 template<
typename OtherDerType>
334 m_value / other.
value(),
339 template<
typename OtherDerType>
347 m_value * other.
value(),
353 *
this = *
this *
other;
357 template<
typename OtherDerType>
360 *
this = *
this *
other;
366 *
this = *
this /
other;
370 template<
typename OtherDerType>
373 *
this = *
this /
other;
385 template<
typename DerivativeType>
420 derived().value() +=
other;
429 derived().value() *
other,
430 derived().derivatives() *
other);
436 return AutoDiffScalar<typename CwiseUnaryOp<bind1st_op<scalar_product_op<Real,Scalar> >, DerType>
::Type >(
443 *
this = *
this *
other;
448 template<
typename DerivativeType>
456 template<
typename BinOp,
typename A,
typename B,
typename RefType>
463 template<
typename UnaryOp,
typename A,
typename RefType>
470 template<
typename UnaryOp,
typename A,
typename RefType>
474 template<
typename A_Scalar,
int A_Rows,
int A_Cols,
int A_Options,
int A_MaxRows,
int A_MaxCols,
typename B>
483 else if (B::SizeAtCompileTime==
Dynamic && a.size()!=0 && b.size()==0)
490 template<
typename A,
typename B_Scalar,
int B_Rows,
int B_Cols,
int B_Options,
int B_MaxRows,
int B_MaxCols>
499 else if (A::SizeAtCompileTime==
Dynamic && b.size()!=0 && a.size()==0)
506 template<
typename A_Scalar,
int A_Rows,
int A_Cols,
int A_Options,
int A_MaxRows,
int A_MaxCols,
507 typename B_Scalar,
int B_Rows,
int B_Cols,
int B_Options,
int B_MaxRows,
int B_MaxCols>
509 Matrix<B_Scalar, B_Rows, B_Cols, B_Options, B_MaxRows, B_MaxCols> > {
528 template<
typename DerType,
typename BinOp>
534 template<
typename DerType,
typename BinOp>
557 #define EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(FUNC,CODE) \ 558 template<typename DerType> \ 559 inline const Eigen::AutoDiffScalar< \ 560 EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(typename Eigen::internal::remove_all<DerType>::type, typename Eigen::internal::traits<typename Eigen::internal::remove_all<DerType>::type>::Scalar, product) > \ 561 FUNC(const Eigen::AutoDiffScalar<DerType>& x) { \ 562 using namespace Eigen; \ 563 typedef typename Eigen::internal::traits<typename Eigen::internal::remove_all<DerType>::type>::Scalar Scalar; \ 564 EIGEN_UNUSED_VARIABLE(sizeof(Scalar)); \ 568 template<
typename DerType>
573 template<
typename DerType>
575 template<
typename DerType>
577 template<
typename DerType>
579 template<
typename DerType,
typename T>
582 return (x <=
y ? ADS(x) : ADS(
y));
584 template<
typename DerType,
typename T>
587 return (x >=
y ? ADS(x) : ADS(
y));
589 template<
typename DerType,
typename T>
592 return (x <
y ? ADS(x) : ADS(
y));
594 template<
typename DerType,
typename T>
597 return (x >
y ? ADS(x) : ADS(
y));
599 template<
typename DerType>
601 return (x.
value() <
y.value() ?
x :
y);
603 template<
typename DerType>
605 return (x.
value() >=
y.value() ?
x :
y);
641 template<typename DerType>
646 using namespace Eigen;
652 template<
typename DerTypeA,
typename DerTypeB>
707 0, DerTypeCleaned::MaxRowsAtCompileTime, DerTypeCleaned::MaxColsAtCompileTime> >
Real;
712 RequireInitialization = 1
720 template <
typename T>
722 :
public numeric_limits<typename T::Scalar> {};
724 template <
typename T>
726 :
public numeric_limits<typename T::Scalar> {};
730 #endif // EIGEN_AUTODIFF_SCALAR_H static void run(A &a, B &b)
Generic expression of a matrix where all coefficients are defined by a functor.
NumTraits< Scalar >::Real Real
bool operator<=(const Scalar &other) const
friend const AutoDiffScalar< typename CwiseUnaryOp< bind1st_op< scalar_product_op< Real, Scalar > >, DerType >::Type > operator*(const Real &other, const AutoDiffScalar< DerivativeType > &a)
#define EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(EXPR, SCALAR, OPNAME)
friend const AutoDiffScalar< CwiseUnaryOp< internal::scalar_opposite_op< Scalar >, const DerType > > operator-(const Scalar &a, const AutoDiffScalar &b)
bool operator>=(const AutoDiffScalar< OtherDerType > &b) const
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
const AutoDiffScalar< DerType > & conj(const AutoDiffScalar< DerType > &x)
Jet< T, N > cos(const Jet< T, N > &f)
AutoDiffScalar< DerType > ReturnType
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TensorUInt128< uint64_t, uint64_t > operator-(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
friend const AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DerType, Scalar, product) > operator*(const Scalar &other, const AutoDiffScalar &a)
Matrix< A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols > A
const AutoDiffScalar< CwiseBinaryOp< internal::scalar_sum_op< Scalar >, const DerType, const typename internal::remove_all< OtherDerType >::type > > operator+(const AutoDiffScalar< OtherDerType > &other) const
A scalar type replacement with automatic differentiation capability.
internal::remove_all< DerivativeType >::type DerType
remove_all< DerivativeType >::type DerType
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const _RhsNested & rhs() const
AutoDiffScalar(const AutoDiffScalar< OtherDerType > &other, typename internal::enable_if< internal::is_same< Scalar, typename internal::traits< typename internal::remove_all< OtherDerType >::type >::Scalar >::value &&internal::is_convertible< OtherDerType, DerType >::value, void *>::type=0)
void make_coherent(const A &a, const B &b)
AutoDiffScalar & operator+=(const Scalar &other)
Jet< T, N > acos(const Jet< T, N > &f)
void make_coherent_expression(CwiseBinaryOp< BinOp, A, B > xpr, const RefType &ref)
EIGEN_DEVICE_FUNC const TanhReturnType tanh() const
Eigen::internal::make_coherent_impl< Matrix< A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols >, Matrix< B_Scalar, B_Rows, B_Cols, B_Options, B_MaxRows, B_MaxCols > >::run static void run(A &a, B &b)
Jet< T, N > sin(const Jet< T, N > &f)
Namespace containing all symbols from the Eigen library.
CleanedUpDerType< DerType >::type() max(const AutoDiffScalar< DerType > &x, const T &y)
DerType::Scalar imag(const AutoDiffScalar< DerType > &)
AutoDiffScalar< DerivativeType > & operator+=(const Real &other)
AutoDiffScalar & operator=(const AutoDiffScalar &other)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
bool operator==(const AutoDiffScalar< OtherDerType > &b) const
AutoDiffScalar & operator/=(const AutoDiffScalar< OtherDerType > &other)
EIGEN_DEVICE_FUNC const SinhReturnType sinh() const
EIGEN_DEVICE_FUNC const LogReturnType log() const
AutoDiffScalar & operator*=(const AutoDiffScalar< OtherDerType > &other)
friend bool operator!=(const Scalar &a, const AutoDiffScalar &b)
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool operator<(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
EIGEN_DEVICE_FUNC const ExpReturnType exp() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Abs2ReturnType abs2() const
Generic expression where a coefficient-wise binary operator is applied to two expressions.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(Index rows, Index cols)
const AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DerType, Scalar, product) > operator*(const Scalar &other) const
Eigen::internal::make_coherent_impl< Matrix< A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols >, Matrix< B_Scalar, B_Rows, B_Cols, B_Options, B_MaxRows, B_MaxCols > >::A Matrix< A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols > A
const AutoDiffScalar< CwiseBinaryOp< internal::scalar_difference_op< Scalar >, const DerType, const typename internal::remove_all< OtherDerType >::type > > operator-(const AutoDiffScalar< OtherDerType > &other) const
Eigen::internal::make_coherent_impl< Matrix< A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols >, Matrix< B_Scalar, B_Rows, B_Cols, B_Options, B_MaxRows, B_MaxCols > >::B Matrix< B_Scalar, B_Rows, B_Cols, B_Options, B_MaxRows, B_MaxCols > B
AutoDiffScalar< DerType > ReturnType
AutoDiffScalar(const Scalar &value, int nbDer, int derNumber)
internal::traits< DerType >::Scalar Scalar
static void run(A &, B &)
NumTraits< Scalar >::Real Real
const AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(CwiseBinaryOp< internal::scalar_difference_op< Scalar > EIGEN_COMMA const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DerType, Scalar, product) EIGEN_COMMA const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(typename internal::remove_all< OtherDerType >::type, Scalar, product) >, Scalar, product) > operator/(const AutoDiffScalar< OtherDerType > &other) const
AutoDiffScalar & operator=(const Scalar &other)
AutoDiffScalar< DerivativeType > & operator*=(const Scalar &other)
const AutoDiffScalar< CwiseBinaryOp< internal::scalar_sum_op< Scalar >, const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DerType, Scalar, product), const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(typename internal::remove_all< OtherDerType >::type, Scalar, product) > > operator*(const AutoDiffScalar< OtherDerType > &other) const
friend bool operator<=(const Scalar &a, const AutoDiffScalar &b)
bool operator!=(const Scalar &other) const
AutoDiffScalar< NewDerType > MakeAutoDiffScalar(const typename NewDerType::Scalar &value, const NewDerType &der)
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorUInt128< uint64_t, uint64_t > operator*(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
AutoDiffScalar(const Real &value)
const DerType & derivatives() const
Reference counting helper.
const AutoDiffScalar< DerType & > operator+(const Real &other) const
AutoDiffScalar< Matrix< typename NumTraits< typename DerTypeCleaned::Scalar >::Real, DerTypeCleaned::RowsAtCompileTime, DerTypeCleaned::ColsAtCompileTime, 0, DerTypeCleaned::MaxRowsAtCompileTime, DerTypeCleaned::MaxColsAtCompileTime > > Real
const AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DerType, Scalar, product) > operator/(const Scalar &other) const
AnnoyingScalar atan2(const AnnoyingScalar &y, const AnnoyingScalar &x)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const _LhsNested & lhs() const
friend const AutoDiffScalar< DerType & > operator+(const Scalar &a, const AutoDiffScalar &b)
AutoDiffScalar & operator*=(const Scalar &other)
const Scalar & value() const
CleanedUpDerType< DerType >::type() min(const AutoDiffScalar< DerType > &x, const T &y)
bool operator!=(const AutoDiffScalar< OtherDerType > &b) const
const AutoDiffScalar< typename CwiseUnaryOp< bind2nd_op< scalar_product_op< Scalar, Real > >, DerType >::Type > operator*(const Real &other) const
internal::auto_diff_special_op< DerivativeType, !internal::is_same< typename internal::traits< typename internal::remove_all< DerivativeType >::type >::Scalar, typename NumTraits< typename internal::traits< typename internal::remove_all< DerivativeType >::type >::Scalar >::Real >::value > Base
traits< DerType >::Scalar Scalar
const AutoDiffScalar< CwiseUnaryOp< internal::scalar_opposite_op< Scalar >, const DerType > > operator-() const
friend bool operator==(const Scalar &a, const AutoDiffScalar &b)
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator>(const bfloat16 &a, const bfloat16 &b)
AutoDiffScalar & operator-=(const Scalar &other)
AutoDiffScalar< typename Eigen::internal::remove_all< DerType >::type::PlainObject > type
AutoDiffScalar(const AutoDiffScalar &other)
AutoDiffScalar & operator-=(const AutoDiffScalar< OtherDerType > &other)
AutoDiffScalar(const Scalar &value, const DerType &der)
EIGEN_DEVICE_FUNC const TanReturnType tan() const
AutoDiffScalar & operator+=(const AutoDiffScalar< OtherDerType > &other)
AutoDiffScalar< DerType > Nested
AutoDiffScalar & operator/=(const Scalar &other)
AutoDiffScalar< DerivativeType > & derived()
const AutoDiffScalar< Matrix< typename internal::traits< typename internal::remove_all< DerTypeA >::type >::Scalar, Dynamic, 1 > > atan2(const AutoDiffScalar< DerTypeA > &a, const AutoDiffScalar< DerTypeB > &b)
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TensorUInt128< uint64_t, uint64_t > operator+(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
internal::remove_all< DerType >::type DerTypeCleaned
NumTraits< typename DerTypeCleaned::Scalar >::Literal Literal
Jet< T, N > sqrt(const Jet< T, N > &f)
Matrix< B_Scalar, B_Rows, B_Cols, B_Options, B_MaxRows, B_MaxCols > B
const AutoDiffScalar< DerType & > operator+(const Scalar &other) const
Jet< T, N > pow(const Jet< T, N > &f, double g)
static void run(A &a, B &b)
Generic expression where a coefficient-wise unary operator is applied to an expression.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const internal::remove_all< XprTypeNested >::type & nestedExpression() const
bool operator>=(const Scalar &other) const
The matrix class, also used for vectors and row-vectors.
EIGEN_DEVICE_FUNC const CoshReturnType cosh() const
const AutoDiffScalar< DerType & > operator-(const Scalar &b) const
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
const AutoDiffScalar< DerType > & real(const AutoDiffScalar< DerType > &x)
EIGEN_DEVICE_FUNC const AsinReturnType asin() const
friend const AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DerType, Scalar, product) > operator/(const Scalar &other, const AutoDiffScalar &a)
EIGEN_DEVICE_FUNC bool abs2(bool x)
friend bool operator>=(const Scalar &a, const AutoDiffScalar &b)
EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(abs, using std::abs;return Eigen::MakeAutoDiffScalar(abs(x.value()), x.derivatives() *(x.value()< 0 ? -1 :1));) EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(abs2
std::ostream & operator<<(std::ostream &s, const Packet16c &v)
AutoDiffScalar & operator=(const AutoDiffScalar< OtherDerType > &other)
bool operator==(const Scalar &other) const
void product(const MatrixType &m)
friend const AutoDiffScalar< DerType & > operator+(const Real &a, const AutoDiffScalar< DerivativeType > &b)
const AutoDiffScalar< DerivativeType > & derived() const
AutoDiffScalar< DerType > NonInteger