10#ifndef EIGEN_AUTODIFF_SCALAR_H
11#define EIGEN_AUTODIFF_SCALAR_H
17template<
typename A,
typename B>
23template<
typename A,
typename B>
35template<
typename NewDerType>
66template<
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*;
108 template<
typename OtherDerType>
110#ifndef EIGEN_PARSED_BY_DOXYGEN
128 template<
typename OtherDerType>
207 template<
typename OtherDerType>
217 template<
typename OtherDerType>
221 (*this) = (*this) + other;
234 (
a -
b.value(), -
b.derivatives());
243 template<
typename OtherDerType>
253 template<
typename OtherDerType>
257 *
this = *
this - other;
325 template<
typename OtherDerType>
339 template<
typename OtherDerType>
353 *
this = *
this * other;
357 template<
typename OtherDerType>
360 *
this = *
this * other;
366 *
this = *
this / other;
370 template<
typename OtherDerType>
373 *
this = *
this / other;
385template<
typename DerivativeType>
420 derived().value() += other;
429 derived().value() * other,
430 derived().derivatives() * other);
438 a.derivatives() * other);
443 *
this = *
this * other;
448template<
typename DerivativeType>
456template<
typename BinOp,
typename A,
typename B,
typename RefType>
463template<
typename UnaryOp,
typename A,
typename RefType>
470template<
typename UnaryOp,
typename A,
typename RefType>
474template<
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)
490template<
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)
506template<
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>
528template<
typename DerType,
typename BinOp>
534template<
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)); \
568template<
typename DerType>
573template<
typename DerType>
575template<
typename DerType>
577template<
typename DerType>
579template<
typename DerType,
typename T>
582 return (
x <=
y ? ADS(
x) : ADS(
y));
584template<
typename DerType,
typename T>
587 return (
x >=
y ? ADS(
x) : ADS(
y));
589template<
typename DerType,
typename T>
592 return (
x <
y ? ADS(
x) : ADS(
y));
594template<
typename DerType,
typename T>
597 return (
x >
y ? ADS(
x) : ADS(
y));
599template<
typename DerType>
601 return (
x.value() <
y.value() ?
x :
y);
603template<
typename DerType>
605 return (
x.value() >=
y.value() ?
x :
y);
619 Scalar sqrtx = sqrt(
x.value());
641template<typename DerType>
646 using namespace Eigen;
652template<
typename DerTypeA,
typename DerTypeB>
662 Scalar squared_hypot =
a.value() *
a.value() +
b.value() *
b.value();
665 ret.derivatives() = (
a.derivatives() *
b.value() -
a.value() *
b.derivatives()) / squared_hypot;
707 0, DerTypeCleaned::MaxRowsAtCompileTime, DerTypeCleaned::MaxColsAtCompileTime> >
Real;
712 RequireInitialization = 1
722 :
public numeric_limits<typename T::Scalar> {};
726 :
public numeric_limits<typename T::Scalar> {};
EIGEN_DEVICE_FUNC const TanReturnType tan() const
Definition ArrayCwiseUnaryOps.h:269
EIGEN_DEVICE_FUNC const LogReturnType log() const
Definition ArrayCwiseUnaryOps.h:128
EIGEN_DEVICE_FUNC const AcosReturnType acos() const
Definition ArrayCwiseUnaryOps.h:297
ArrayXXi a
Definition Array_initializer_list_23_cxx11.cpp:1
#define EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY(FUNC, CODE)
Definition AutoDiffScalar.h:557
#define EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(EXPR, SCALAR, OPNAME)
Definition Macros.h:1347
#define EIGEN_COMMA
Definition Macros.h:904
Scalar * b
Definition benchVecAdd.cpp:17
SCALAR Scalar
Definition bench_gemm.cpp:46
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition bench_gemm.cpp:49
mp::number< mp::cpp_dec_float< 100 >, mp::et_on > Real
Definition boostmultiprec.cpp:78
A scalar type replacement with automatic differentiation capability.
Definition AutoDiffScalar.h:71
AutoDiffScalar()
Definition AutoDiffScalar.h:84
friend const AutoDiffScalar< DerType & > operator+(const Scalar &a, const AutoDiffScalar &b)
Definition AutoDiffScalar.h:186
internal::traits< DerType >::Scalar Scalar
Definition AutoDiffScalar.h:77
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
Definition AutoDiffScalar.h:343
AutoDiffScalar & operator=(const Scalar &other)
Definition AutoDiffScalar.h:143
NumTraits< Scalar >::Real Real
Definition AutoDiffScalar.h:78
friend std::ostream & operator<<(std::ostream &s, const AutoDiffScalar &a)
Definition AutoDiffScalar.h:119
Scalar m_value
Definition AutoDiffScalar.h:378
const AutoDiffScalar< DerType & > operator+(const Scalar &other) const
Definition AutoDiffScalar.h:181
bool operator==(const AutoDiffScalar< OtherDerType > &b) const
Definition AutoDiffScalar.h:178
const AutoDiffScalar< CwiseBinaryOp< internal::scalar_difference_op< Scalar >, const DerType, const typename internal::remove_all< OtherDerType >::type > > operator-(const AutoDiffScalar< OtherDerType > &other) const
Definition AutoDiffScalar.h:245
const AutoDiffScalar< DerType & > operator-(const Scalar &b) const
Definition AutoDiffScalar.h:225
bool operator!=(const AutoDiffScalar< OtherDerType > &b) const
Definition AutoDiffScalar.h:179
internal::remove_all< DerivativeType >::type DerType
Definition AutoDiffScalar.h:76
friend bool operator<(const Scalar &a, const AutoDiffScalar &b)
Definition AutoDiffScalar.h:167
DerType m_derivatives
Definition AutoDiffScalar.h:379
AutoDiffScalar & operator*=(const Scalar &other)
Definition AutoDiffScalar.h:351
AutoDiffScalar & operator+=(const AutoDiffScalar< OtherDerType > &other)
Definition AutoDiffScalar.h:219
AutoDiffScalar & operator/=(const AutoDiffScalar< OtherDerType > &other)
Definition AutoDiffScalar.h:371
AutoDiffScalar(const AutoDiffScalar &other)
Definition AutoDiffScalar.h:124
AutoDiffScalar & operator*=(const AutoDiffScalar< OtherDerType > &other)
Definition AutoDiffScalar.h:358
AutoDiffScalar & operator=(const AutoDiffScalar &other)
Definition AutoDiffScalar.h:136
bool operator<=(const Scalar &other) const
Definition AutoDiffScalar.h:161
AutoDiffScalar & operator=(const AutoDiffScalar< OtherDerType > &other)
Definition AutoDiffScalar.h:129
const DerType & derivatives() const
Definition AutoDiffScalar.h:157
bool operator<=(const AutoDiffScalar< OtherDerType > &b) const
Definition AutoDiffScalar.h:175
friend const AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DerType, Scalar, product) > operator/(const Scalar &other, const AutoDiffScalar &a)
Definition AutoDiffScalar.h:304
friend bool operator>(const Scalar &a, const AutoDiffScalar &b)
Definition AutoDiffScalar.h:169
bool operator>=(const Scalar &other) const
Definition AutoDiffScalar.h:163
AutoDiffScalar(const Scalar &value, int nbDer, int derNumber)
Definition AutoDiffScalar.h:88
friend bool operator==(const Scalar &a, const AutoDiffScalar &b)
Definition AutoDiffScalar.h:171
AutoDiffScalar & operator/=(const Scalar &other)
Definition AutoDiffScalar.h:364
bool operator==(const Scalar &other) const
Definition AutoDiffScalar.h:164
friend bool operator!=(const Scalar &a, const AutoDiffScalar &b)
Definition AutoDiffScalar.h:172
bool operator!=(const Scalar &other) const
Definition AutoDiffScalar.h:165
AutoDiffScalar & operator-=(const AutoDiffScalar< OtherDerType > &other)
Definition AutoDiffScalar.h:255
const Scalar & value() const
Definition AutoDiffScalar.h:154
const AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DerType, Scalar, product) > operator*(const Scalar &other) const
Definition AutoDiffScalar.h:270
friend const AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DerType, Scalar, product) > operator*(const Scalar &other, const AutoDiffScalar &a)
Definition AutoDiffScalar.h:276
friend bool operator<=(const Scalar &a, const AutoDiffScalar &b)
Definition AutoDiffScalar.h:168
AutoDiffScalar(const Real &value)
Definition AutoDiffScalar.h:96
const AutoDiffScalar< CwiseUnaryOp< internal::scalar_opposite_op< Scalar >, const DerType > > operator-() const
Definition AutoDiffScalar.h:262
Scalar & value()
Definition AutoDiffScalar.h:155
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
Definition AutoDiffScalar.h:330
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
Definition AutoDiffScalar.h:75
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)
Definition AutoDiffScalar.h:109
AutoDiffScalar(const Scalar &value, const DerType &der)
Definition AutoDiffScalar.h:104
friend const AutoDiffScalar< CwiseUnaryOp< internal::scalar_opposite_op< Scalar >, const DerType > > operator-(const Scalar &a, const AutoDiffScalar &b)
Definition AutoDiffScalar.h:231
AutoDiffScalar & operator+=(const Scalar &other)
Definition AutoDiffScalar.h:201
AutoDiffScalar & operator-=(const Scalar &other)
Definition AutoDiffScalar.h:237
friend bool operator>=(const Scalar &a, const AutoDiffScalar &b)
Definition AutoDiffScalar.h:170
DerType & derivatives()
Definition AutoDiffScalar.h:158
const AutoDiffScalar< CwiseBinaryOp< internal::scalar_sum_op< Scalar >, const DerType, const typename internal::remove_all< OtherDerType >::type > > operator+(const AutoDiffScalar< OtherDerType > &other) const
Definition AutoDiffScalar.h:209
const AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DerType, Scalar, product) > operator/(const Scalar &other) const
Definition AutoDiffScalar.h:298
bool operator>=(const AutoDiffScalar< OtherDerType > &b) const
Definition AutoDiffScalar.h:177
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition CwiseBinaryOp.h:84
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
const Scalar & value() const
Definition SparseUtil.h:178
#define abs(x)
Definition datatypes.h:17
#define min(a, b)
Definition datatypes.h:19
#define max(a, b)
Definition datatypes.h:20
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
Definition gnuplot_common_settings.hh:12
RealScalar s
Definition level1_cplx_impl.h:126
Scalar * y
Definition level1_cplx_impl.h:124
DenseIndex ret
Definition level1_cplx_impl.h:44
void make_coherent_expression(CwiseBinaryOp< BinOp, A, B > xpr, const RefType &ref)
Definition AutoDiffScalar.h:457
void make_coherent(const A &a, const B &b)
Definition AutoDiffScalar.h:24
EIGEN_DEVICE_FUNC bool abs2(bool x)
Definition MathFunctions.h:1292
Namespace containing all symbols from the Eigen library.
Definition bench_norm.cpp:85
const AutoDiffScalar< DerType > & conj(const AutoDiffScalar< DerType > &x)
Definition AutoDiffScalar.h:574
AutoDiffScalar< NewDerType > MakeAutoDiffScalar(const typename NewDerType::Scalar &value, const NewDerType &der)
Definition AutoDiffScalar.h:36
const AutoDiffScalar< Matrix< typename internal::traits< typename internal::remove_all< DerTypeA >::type >::Scalar, Dynamic, 1 > > atan2(const AutoDiffScalar< DerTypeA > &a, const AutoDiffScalar< DerTypeB > &b)
Definition AutoDiffScalar.h:654
Scalar expx
Definition AutoDiffScalar.h:634
const int Dynamic
Definition Constants.h:22
Definition BandTriangularSolver.h:13
void product(const MatrixType &m)
Definition product.h:20
Definition AutoDiffScalar.h:569
AutoDiffScalar< typename Eigen::internal::remove_all< DerType >::type::PlainObject > type
Definition AutoDiffScalar.h:570
AutoDiffScalar< DerType > NonInteger
Definition AutoDiffScalar.h:708
NumTraits< typenameDerTypeCleaned::Scalar >::Literal Literal
Definition AutoDiffScalar.h:710
internal::remove_all< DerType >::type DerTypeCleaned
Definition AutoDiffScalar.h:705
AutoDiffScalar< DerType > Nested
Definition AutoDiffScalar.h:709
AutoDiffScalar< Matrix< typename NumTraits< typename DerTypeCleaned::Scalar >::Real, DerTypeCleaned::RowsAtCompileTime, DerTypeCleaned::ColsAtCompileTime, 0, DerTypeCleaned::MaxRowsAtCompileTime, DerTypeCleaned::MaxColsAtCompileTime > > Real
Definition AutoDiffScalar.h:707
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition NumTraits.h:233
AutoDiffScalar< DerType > ReturnType
Definition AutoDiffScalar.h:531
AutoDiffScalar< DerType > ReturnType
Definition AutoDiffScalar.h:537
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition XprHelper.h:806
remove_all< DerivativeType >::type DerType
Definition AutoDiffScalar.h:390
AutoDiffScalar< DerivativeType > & operator*=(const Scalar &other)
Definition AutoDiffScalar.h:441
friend const AutoDiffScalar< typename CwiseUnaryOp< bind1st_op< scalar_product_op< Real, Scalar > >, DerType >::Type > operator*(const Real &other, const AutoDiffScalar< DerivativeType > &a)
Definition AutoDiffScalar.h:434
const AutoDiffScalar< typename CwiseUnaryOp< bind2nd_op< scalar_product_op< Scalar, Real > >, DerType >::Type > operator*(const Real &other) const
Definition AutoDiffScalar.h:426
AutoDiffScalar< DerivativeType > & derived()
Definition AutoDiffScalar.h:405
NumTraits< Scalar >::Real Real
Definition AutoDiffScalar.h:392
friend const AutoDiffScalar< DerType & > operator+(const Real &a, const AutoDiffScalar< DerivativeType > &b)
Definition AutoDiffScalar.h:413
const AutoDiffScalar< DerType & > operator+(const Real &other) const
Definition AutoDiffScalar.h:408
AutoDiffScalar< DerivativeType > & operator+=(const Real &other)
Definition AutoDiffScalar.h:418
traits< DerType >::Scalar Scalar
Definition AutoDiffScalar.h:391
const AutoDiffScalar< DerivativeType > & derived() const
Definition AutoDiffScalar.h:404
Definition AutoDiffScalar.h:29
Matrix< B_Scalar, B_Rows, B_Cols, B_Options, B_MaxRows, B_MaxCols > B
Definition AutoDiffScalar.h:492
static void run(A &a, B &b)
Definition AutoDiffScalar.h:493
Matrix< A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols > A
Definition AutoDiffScalar.h:476
static void run(A &a, B &b)
Definition AutoDiffScalar.h:477
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)
Definition AutoDiffScalar.h:512
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
Definition AutoDiffScalar.h:510
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
Definition AutoDiffScalar.h:511
Definition AutoDiffScalar.h:18
static void run(A &, B &)
Definition AutoDiffScalar.h:19
Definition ForwardDeclarations.h:17