AutoDiffScalar.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_AUTODIFF_SCALAR_H
11 #define EIGEN_AUTODIFF_SCALAR_H
12 
13 namespace Eigen {
14 
15 namespace internal {
16 
17 template<typename A, typename B>
19  static void run(A&, B&) {}
20 };
21 
22 // resize a to match b is a.size()==0, and conversely.
23 template<typename A, typename B>
24 void make_coherent(const A& a, const B&b)
25 {
26  make_coherent_impl<A,B>::run(a.const_cast_derived(), b.const_cast_derived());
27 }
28 
29 template<typename DerivativeType, bool Enable> struct auto_diff_special_op;
30 
31 } // end namespace internal
32 
33 template<typename DerivativeType> class AutoDiffScalar;
34 
35 template<typename NewDerType>
36 inline AutoDiffScalar<NewDerType> MakeAutoDiffScalar(const typename NewDerType::Scalar& value, const NewDerType &der) {
38 }
39 
66 template<typename DerivativeType>
67 class AutoDiffScalar
68  : public internal::auto_diff_special_op
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>
71 {
72  public:
73  typedef internal::auto_diff_special_op
78  typedef typename NumTraits<Scalar>::Real Real;
79 
80  using Base::operator+;
81  using Base::operator*;
82 
85 
88  AutoDiffScalar(const Scalar& value, int nbDer, int derNumber)
89  : m_value(value), m_derivatives(DerType::Zero(nbDer))
90  {
91  m_derivatives.coeffRef(derNumber) = Scalar(1);
92  }
93 
96  /*explicit*/ AutoDiffScalar(const Real& value)
97  : m_value(value)
98  {
99  if(m_derivatives.size()>0)
100  m_derivatives.setZero();
101  }
102 
104  AutoDiffScalar(const Scalar& value, const DerType& der)
105  : m_value(value), m_derivatives(der)
106  {}
107 
108  template<typename OtherDerType>
110 #ifndef EIGEN_PARSED_BY_DOXYGEN
111  , typename internal::enable_if<
114 #endif
115  )
117  {}
118 
119  friend std::ostream & operator << (std::ostream & s, const AutoDiffScalar& a)
120  {
121  return s << a.value();
122  }
123 
126  {}
127 
128  template<typename OtherDerType>
130  {
131  m_value = other.value();
132  m_derivatives = other.derivatives();
133  return *this;
134  }
135 
137  {
138  m_value = other.value();
139  m_derivatives = other.derivatives();
140  return *this;
141  }
142 
144  {
145  m_value = other;
146  if(m_derivatives.size()>0)
147  m_derivatives.setZero();
148  return *this;
149  }
150 
151 // inline operator const Scalar& () const { return m_value; }
152 // inline operator Scalar& () { return m_value; }
153 
154  inline const Scalar& value() const { return m_value; }
155  inline Scalar& value() { return m_value; }
156 
157  inline const DerType& derivatives() const { return m_derivatives; }
158  inline DerType& derivatives() { return m_derivatives; }
159 
160  inline bool operator< (const Scalar& other) const { return m_value < other; }
161  inline bool operator<=(const Scalar& other) const { return m_value <= other; }
162  inline bool operator> (const Scalar& other) const { return m_value > other; }
163  inline bool operator>=(const Scalar& other) const { return m_value >= other; }
164  inline bool operator==(const Scalar& other) const { return m_value == other; }
165  inline bool operator!=(const Scalar& other) const { return m_value != other; }
166 
167  friend inline bool operator< (const Scalar& a, const AutoDiffScalar& b) { return a < b.value(); }
168  friend inline bool operator<=(const Scalar& a, const AutoDiffScalar& b) { return a <= b.value(); }
169  friend inline bool operator> (const Scalar& a, const AutoDiffScalar& b) { return a > b.value(); }
170  friend inline bool operator>=(const Scalar& a, const AutoDiffScalar& b) { return a >= b.value(); }
171  friend inline bool operator==(const Scalar& a, const AutoDiffScalar& b) { return a == b.value(); }
172  friend inline bool operator!=(const Scalar& a, const AutoDiffScalar& b) { return a != b.value(); }
173 
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(); }
176  template<typename OtherDerType> inline bool operator> (const AutoDiffScalar<OtherDerType>& b) const { return m_value > b.value(); }
177  template<typename OtherDerType> inline bool operator>=(const AutoDiffScalar<OtherDerType>& b) const { return m_value >= b.value(); }
178  template<typename OtherDerType> inline bool operator==(const AutoDiffScalar<OtherDerType>& b) const { return m_value == b.value(); }
179  template<typename OtherDerType> inline bool operator!=(const AutoDiffScalar<OtherDerType>& b) const { return m_value != b.value(); }
180 
181  inline const AutoDiffScalar<DerType&> operator+(const Scalar& other) const
182  {
184  }
185 
186  friend inline const AutoDiffScalar<DerType&> operator+(const Scalar& a, const AutoDiffScalar& b)
187  {
188  return AutoDiffScalar<DerType&>(a + b.value(), b.derivatives());
189  }
190 
191 // inline const AutoDiffScalar<DerType&> operator+(const Real& other) const
192 // {
193 // return AutoDiffScalar<DerType&>(m_value + other, m_derivatives);
194 // }
195 
196 // friend inline const AutoDiffScalar<DerType&> operator+(const Real& a, const AutoDiffScalar& b)
197 // {
198 // return AutoDiffScalar<DerType&>(a + b.value(), b.derivatives());
199 // }
200 
202  {
203  value() += other;
204  return *this;
205  }
206 
207  template<typename OtherDerType>
210  {
213  m_value + other.value(),
214  m_derivatives + other.derivatives());
215  }
216 
217  template<typename OtherDerType>
218  inline AutoDiffScalar&
220  {
221  (*this) = (*this) + other;
222  return *this;
223  }
224 
225  inline const AutoDiffScalar<DerType&> operator-(const Scalar& b) const
226  {
228  }
229 
232  {
234  (a - b.value(), -b.derivatives());
235  }
236 
238  {
239  value() -= other;
240  return *this;
241  }
242 
243  template<typename OtherDerType>
246  {
249  m_value - other.value(),
250  m_derivatives - other.derivatives());
251  }
252 
253  template<typename OtherDerType>
254  inline AutoDiffScalar&
256  {
257  *this = *this - other;
258  return *this;
259  }
260 
262  operator-() const
263  {
265  -m_value,
266  -m_derivatives);
267  }
268 
270  operator*(const Scalar& other) const
271  {
273  }
274 
277  {
278  return MakeAutoDiffScalar(a.value() * other, a.derivatives() * other);
279  }
280 
281 // inline const AutoDiffScalar<typename CwiseUnaryOp<internal::scalar_multiple_op<Real>, DerType>::Type >
282 // operator*(const Real& other) const
283 // {
284 // return AutoDiffScalar<typename CwiseUnaryOp<internal::scalar_multiple_op<Real>, DerType>::Type >(
285 // m_value * other,
286 // (m_derivatives * other));
287 // }
288 //
289 // friend inline const AutoDiffScalar<typename CwiseUnaryOp<internal::scalar_multiple_op<Real>, DerType>::Type >
290 // operator*(const Real& other, const AutoDiffScalar& a)
291 // {
292 // return AutoDiffScalar<typename CwiseUnaryOp<internal::scalar_multiple_op<Real>, DerType>::Type >(
293 // a.value() * other,
294 // a.derivatives() * other);
295 // }
296 
298  operator/(const Scalar& other) const
299  {
301  }
302 
305  {
306  return MakeAutoDiffScalar(other / a.value(), a.derivatives() * (Scalar(-other) / (a.value()*a.value())));
307  }
308 
309 // inline const AutoDiffScalar<typename CwiseUnaryOp<internal::scalar_multiple_op<Real>, DerType>::Type >
310 // operator/(const Real& other) const
311 // {
312 // return AutoDiffScalar<typename CwiseUnaryOp<internal::scalar_multiple_op<Real>, DerType>::Type >(
313 // m_value / other,
314 // (m_derivatives * (Real(1)/other)));
315 // }
316 //
317 // friend inline const AutoDiffScalar<typename CwiseUnaryOp<internal::scalar_multiple_op<Real>, DerType>::Type >
318 // operator/(const Real& other, const AutoDiffScalar& a)
319 // {
320 // return AutoDiffScalar<typename CwiseUnaryOp<internal::scalar_multiple_op<Real>, DerType>::Type >(
321 // other / a.value(),
322 // a.derivatives() * (-Real(1)/other));
323 // }
324 
325  template<typename OtherDerType>
331  {
333  return MakeAutoDiffScalar(
334  m_value / other.value(),
335  ((m_derivatives * other.value()) - (other.derivatives() * m_value))
336  * (Scalar(1)/(other.value()*other.value())));
337  }
338 
339  template<typename OtherDerType>
344  {
346  return MakeAutoDiffScalar(
347  m_value * other.value(),
348  (m_derivatives * other.value()) + (other.derivatives() * m_value));
349  }
350 
352  {
353  *this = *this * other;
354  return *this;
355  }
356 
357  template<typename OtherDerType>
359  {
360  *this = *this * other;
361  return *this;
362  }
363 
365  {
366  *this = *this / other;
367  return *this;
368  }
369 
370  template<typename OtherDerType>
372  {
373  *this = *this / other;
374  return *this;
375  }
376 
377  protected:
380 
381 };
382 
383 namespace internal {
384 
385 template<typename DerivativeType>
386 struct auto_diff_special_op<DerivativeType, true>
387 // : auto_diff_scalar_op<DerivativeType, typename NumTraits<Scalar>::Real,
388 // is_same<Scalar,typename NumTraits<Scalar>::Real>::value>
389 {
391  typedef typename traits<DerType>::Scalar Scalar;
392  typedef typename NumTraits<Scalar>::Real Real;
393 
394 // typedef auto_diff_scalar_op<DerivativeType, typename NumTraits<Scalar>::Real,
395 // is_same<Scalar,typename NumTraits<Scalar>::Real>::value> Base;
396 
397 // using Base::operator+;
398 // using Base::operator+=;
399 // using Base::operator-;
400 // using Base::operator-=;
401 // using Base::operator*;
402 // using Base::operator*=;
403 
404  const AutoDiffScalar<DerivativeType>& derived() const { return *static_cast<const AutoDiffScalar<DerivativeType>*>(this); }
406 
407 
408  inline const AutoDiffScalar<DerType&> operator+(const Real& other) const
409  {
410  return AutoDiffScalar<DerType&>(derived().value() + other, derived().derivatives());
411  }
412 
414  {
415  return AutoDiffScalar<DerType&>(a + b.value(), b.derivatives());
416  }
417 
419  {
420  derived().value() += other;
421  return derived();
422  }
423 
424 
426  operator*(const Real& other) const
427  {
429  derived().value() * other,
430  derived().derivatives() * other);
431  }
432 
435  {
437  a.value() * other,
438  a.derivatives() * other);
439  }
440 
442  {
443  *this = *this * other;
444  return derived();
445  }
446 };
447 
448 template<typename DerivativeType>
449 struct auto_diff_special_op<DerivativeType, false>
450 {
451  void operator*() const;
452  void operator-() const;
453  void operator+() const;
454 };
455 
456 template<typename BinOp, typename A, typename B, typename RefType>
458 {
459  make_coherent(xpr.const_cast_derived().lhs(), ref);
460  make_coherent(xpr.const_cast_derived().rhs(), ref);
461 }
462 
463 template<typename UnaryOp, typename A, typename RefType>
464 void make_coherent_expression(const CwiseUnaryOp<UnaryOp,A> &xpr, const RefType &ref)
465 {
466  make_coherent(xpr.nestedExpression().const_cast_derived(), ref);
467 }
468 
469 // needed for compilation only
470 template<typename UnaryOp, typename A, typename RefType>
472 {}
473 
474 template<typename A_Scalar, int A_Rows, int A_Cols, int A_Options, int A_MaxRows, int A_MaxCols, typename B>
475 struct make_coherent_impl<Matrix<A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols>, B> {
477  static void run(A& a, B& b) {
478  if((A_Rows==Dynamic || A_Cols==Dynamic) && (a.size()==0))
479  {
480  a.resize(b.size());
481  a.setZero();
482  }
483  else if (B::SizeAtCompileTime==Dynamic && a.size()!=0 && b.size()==0)
484  {
486  }
487  }
488 };
489 
490 template<typename A, typename B_Scalar, int B_Rows, int B_Cols, int B_Options, int B_MaxRows, int B_MaxCols>
491 struct make_coherent_impl<A, Matrix<B_Scalar, B_Rows, B_Cols, B_Options, B_MaxRows, B_MaxCols> > {
493  static void run(A& a, B& b) {
494  if((B_Rows==Dynamic || B_Cols==Dynamic) && (b.size()==0))
495  {
496  b.resize(a.size());
497  b.setZero();
498  }
499  else if (A::SizeAtCompileTime==Dynamic && b.size()!=0 && a.size()==0)
500  {
502  }
503  }
504 };
505 
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>
508 struct make_coherent_impl<Matrix<A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols>,
509  Matrix<B_Scalar, B_Rows, B_Cols, B_Options, B_MaxRows, B_MaxCols> > {
512  static void run(A& a, B& b) {
513  if((A_Rows==Dynamic || A_Cols==Dynamic) && (a.size()==0))
514  {
515  a.resize(b.size());
516  a.setZero();
517  }
518  else if((B_Rows==Dynamic || B_Cols==Dynamic) && (b.size()==0))
519  {
520  b.resize(a.size());
521  b.setZero();
522  }
523  }
524 };
525 
526 } // end namespace internal
527 
528 template<typename DerType, typename BinOp>
529 struct ScalarBinaryOpTraits<AutoDiffScalar<DerType>,typename DerType::Scalar,BinOp>
530 {
532 };
533 
534 template<typename DerType, typename BinOp>
535 struct ScalarBinaryOpTraits<typename DerType::Scalar,AutoDiffScalar<DerType>, BinOp>
536 {
538 };
539 
540 
541 // The following is an attempt to let Eigen's known about expression template, but that's more tricky!
542 
543 // template<typename DerType, typename BinOp>
544 // struct ScalarBinaryOpTraits<AutoDiffScalar<DerType>,AutoDiffScalar<DerType>, BinOp>
545 // {
546 // enum { Defined = 1 };
547 // typedef AutoDiffScalar<typename DerType::PlainObject> ReturnType;
548 // };
549 //
550 // template<typename DerType1,typename DerType2, typename BinOp>
551 // struct ScalarBinaryOpTraits<AutoDiffScalar<DerType1>,AutoDiffScalar<DerType2>, BinOp>
552 // {
553 // enum { Defined = 1 };//internal::is_same<typename DerType1::Scalar,typename DerType2::Scalar>::value };
554 // typedef AutoDiffScalar<typename DerType1::PlainObject> ReturnType;
555 // };
556 
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)); \
565  CODE; \
566  }
567 
568 template<typename DerType>
571 };
572 
573 template<typename DerType>
574 inline const AutoDiffScalar<DerType>& conj(const AutoDiffScalar<DerType>& x) { return x; }
575 template<typename DerType>
576 inline const AutoDiffScalar<DerType>& real(const AutoDiffScalar<DerType>& x) { return x; }
577 template<typename DerType>
578 inline typename DerType::Scalar imag(const AutoDiffScalar<DerType>&) { return 0.; }
579 template<typename DerType, typename T>
580 inline typename CleanedUpDerType<DerType>::type (min)(const AutoDiffScalar<DerType>& x, const T& y) {
581  typedef typename CleanedUpDerType<DerType>::type ADS;
582  return (x <= y ? ADS(x) : ADS(y));
583 }
584 template<typename DerType, typename T>
585 inline typename CleanedUpDerType<DerType>::type (max)(const AutoDiffScalar<DerType>& x, const T& y) {
586  typedef typename CleanedUpDerType<DerType>::type ADS;
587  return (x >= y ? ADS(x) : ADS(y));
588 }
589 template<typename DerType, typename T>
590 inline typename CleanedUpDerType<DerType>::type (min)(const T& x, const AutoDiffScalar<DerType>& y) {
591  typedef typename CleanedUpDerType<DerType>::type ADS;
592  return (x < y ? ADS(x) : ADS(y));
593 }
594 template<typename DerType, typename T>
595 inline typename CleanedUpDerType<DerType>::type (max)(const T& x, const AutoDiffScalar<DerType>& y) {
596  typedef typename CleanedUpDerType<DerType>::type ADS;
597  return (x > y ? ADS(x) : ADS(y));
598 }
599 template<typename DerType>
601  return (x.value() < y.value() ? x : y);
602 }
603 template<typename DerType>
605  return (x.value() >= y.value() ? x : y);
606 }
607 
608 
610  using std::abs;
611  return Eigen::MakeAutoDiffScalar(abs(x.value()), x.derivatives() * (x.value()<0 ? -1 : 1) );)
612 
614  using numext::abs2;
615  return Eigen::MakeAutoDiffScalar(abs2(x.value()), x.derivatives() * (Scalar(2)*x.value()));)
616 
618  using std::sqrt;
619  Scalar sqrtx = sqrt(x.value());
620  return Eigen::MakeAutoDiffScalar(sqrtx,x.derivatives() * (Scalar(0.5) / sqrtx));)
621 
623  using std::cos;
624  using std::sin;
625  return Eigen::MakeAutoDiffScalar(cos(x.value()), x.derivatives() * (-sin(x.value())));)
626 
628  using std::sin;
629  using std::cos;
630  return Eigen::MakeAutoDiffScalar(sin(x.value()),x.derivatives() * cos(x.value()));)
631 
633  using std::exp;
634  Scalar expx = exp(x.value());
635  return Eigen::MakeAutoDiffScalar(expx,x.derivatives() * expx);)
636 
638  using std::log;
639  return Eigen::MakeAutoDiffScalar(log(x.value()),x.derivatives() * (Scalar(1)/x.value()));)
640 
641 template<typename DerType>
642 inline const Eigen::AutoDiffScalar<
645 {
646  using namespace Eigen;
647  using std::pow;
648  return Eigen::MakeAutoDiffScalar(pow(x.value(),y), x.derivatives() * (y * pow(x.value(),y-1)));
649 }
650 
651 
652 template<typename DerTypeA,typename DerTypeB>
655 {
656  using std::atan2;
658  typedef AutoDiffScalar<Matrix<Scalar,Dynamic,1> > PlainADS;
659  PlainADS ret;
660  ret.value() = atan2(a.value(), b.value());
661 
662  Scalar squared_hypot = a.value() * a.value() + b.value() * b.value();
663 
664  // if (squared_hypot==0) the derivation is undefined and the following results in a NaN:
665  ret.derivatives() = (a.derivatives() * b.value() - a.value() * b.derivatives()) / squared_hypot;
666 
667  return ret;
668 }
669 
671  using std::tan;
672  using std::cos;
673  return Eigen::MakeAutoDiffScalar(tan(x.value()),x.derivatives() * (Scalar(1)/numext::abs2(cos(x.value()))));)
674 
676  using std::sqrt;
677  using std::asin;
678  return Eigen::MakeAutoDiffScalar(asin(x.value()),x.derivatives() * (Scalar(1)/sqrt(1-numext::abs2(x.value()))));)
679 
681  using std::sqrt;
682  using std::acos;
683  return Eigen::MakeAutoDiffScalar(acos(x.value()),x.derivatives() * (Scalar(-1)/sqrt(1-numext::abs2(x.value()))));)
684 
686  using std::cosh;
687  using std::tanh;
688  return Eigen::MakeAutoDiffScalar(tanh(x.value()),x.derivatives() * (Scalar(1)/numext::abs2(cosh(x.value()))));)
689 
691  using std::sinh;
692  using std::cosh;
693  return Eigen::MakeAutoDiffScalar(sinh(x.value()),x.derivatives() * cosh(x.value()));)
694 
696  using std::sinh;
697  using std::cosh;
698  return Eigen::MakeAutoDiffScalar(cosh(x.value()),x.derivatives() * sinh(x.value()));)
699 
701 
702 template<typename DerType> struct NumTraits<AutoDiffScalar<DerType> >
704 {
706  typedef AutoDiffScalar<Matrix<typename NumTraits<typename DerTypeCleaned::Scalar>::Real,DerTypeCleaned::RowsAtCompileTime,DerTypeCleaned::ColsAtCompileTime,
707  0, DerTypeCleaned::MaxRowsAtCompileTime, DerTypeCleaned::MaxColsAtCompileTime> > Real;
711  enum{
712  RequireInitialization = 1
713  };
714 };
715 
716 }
717 
718 namespace std {
719 
720 template <typename T>
721 class numeric_limits<Eigen::AutoDiffScalar<T> >
722  : public numeric_limits<typename T::Scalar> {};
723 
724 template <typename T>
725 class numeric_limits<Eigen::AutoDiffScalar<T&> >
726  : public numeric_limits<typename T::Scalar> {};
727 
728 } // namespace std
729 
730 #endif // EIGEN_AUTODIFF_SCALAR_H
Eigen::conj
const AutoDiffScalar< DerType > & conj(const AutoDiffScalar< DerType > &x)
Definition: AutoDiffScalar.h:574
Eigen::AutoDiffScalar::operator-
const AutoDiffScalar< CwiseUnaryOp< internal::scalar_opposite_op< Scalar >, const DerType > > operator-() const
Definition: AutoDiffScalar.h:262
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Eigen::internal::auto_diff_special_op< DerivativeType, true >::Real
NumTraits< Scalar >::Real Real
Definition: AutoDiffScalar.h:392
Eigen::internal::auto_diff_special_op< DerivativeType, true >::derived
AutoDiffScalar< DerivativeType > & derived()
Definition: AutoDiffScalar.h:405
Eigen::max
CleanedUpDerType< DerType >::type() max(const AutoDiffScalar< DerType > &x, const T &y)
Definition: AutoDiffScalar.h:585
Eigen::atan2
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
gtsam.examples.DogLegOptimizerExample.type
type
Definition: DogLegOptimizerExample.py:111
Eigen::AutoDiffScalar::derivatives
DerType & derivatives()
Definition: AutoDiffScalar.h:158
Eigen::AutoDiffScalar
A scalar type replacement with automatic differentiation capability.
Definition: AutoDiffScalar.h:33
s
RealScalar s
Definition: level1_cplx_impl.h:126
Eigen::CwiseBinaryOp
Generic expression where a coefficient-wise binary operator is applied to two expressions.
Definition: CwiseBinaryOp.h:77
Eigen::internal::auto_diff_special_op< DerivativeType, true >::derived
const AutoDiffScalar< DerivativeType > & derived() const
Definition: AutoDiffScalar.h:404
Eigen::internal::make_coherent_impl< Matrix< A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols >, B >::A
Matrix< A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols > A
Definition: AutoDiffScalar.h:476
ceres::sin
Jet< T, N > sin(const Jet< T, N > &f)
Definition: jet.h:439
Eigen::internal::auto_diff_special_op< DerivativeType, true >::operator*=
AutoDiffScalar< DerivativeType > & operator*=(const Scalar &other)
Definition: AutoDiffScalar.h:441
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::remove_all
Definition: Meta.h:126
Eigen::AutoDiffScalar::AutoDiffScalar
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
b
Scalar * b
Definition: benchVecAdd.cpp:17
Eigen::AutoDiffScalar::operator!=
bool operator!=(const Scalar &other) const
Definition: AutoDiffScalar.h:165
x
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
Eigen::AutoDiffScalar::operator*
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
ret
DenseIndex ret
Definition: level1_cplx_impl.h:44
Eigen::AutoDiffScalar::operator/=
AutoDiffScalar & operator/=(const Scalar &other)
Definition: AutoDiffScalar.h:364
B
Definition: test_numpy_dtypes.cpp:299
Eigen::CleanedUpDerType
Definition: AutoDiffScalar.h:569
Eigen::AutoDiffScalar::operator<=
bool operator<=(const Scalar &other) const
Definition: AutoDiffScalar.h:161
Eigen::NumTraits< AutoDiffScalar< DerType > >::Real
AutoDiffScalar< Matrix< typename NumTraits< typename DerTypeCleaned::Scalar >::Real, DerTypeCleaned::RowsAtCompileTime, DerTypeCleaned::ColsAtCompileTime, 0, DerTypeCleaned::MaxRowsAtCompileTime, DerTypeCleaned::MaxColsAtCompileTime > > Real
Definition: AutoDiffScalar.h:707
type
Definition: pytypes.h:1525
Eigen::AutoDiffScalar::operator-
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
Eigen::AutoDiffScalar::derivatives
const DerType & derivatives() const
Definition: AutoDiffScalar.h:157
Eigen::AutoDiffScalar::operator+=
AutoDiffScalar & operator+=(const Scalar &other)
Definition: AutoDiffScalar.h:201
Eigen::AutoDiffScalar::Scalar
internal::traits< DerType >::Scalar Scalar
Definition: AutoDiffScalar.h:77
log
const EIGEN_DEVICE_FUNC LogReturnType log() const
Definition: ArrayCwiseUnaryOps.h:128
Eigen::ScalarBinaryOpTraits
Determines whether the given binary operation of two numeric types is allowed and what the scalar ret...
Definition: XprHelper.h:801
abs2
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE Abs2ReturnType abs2() const
Definition: ArrayCwiseUnaryOps.h:80
Eigen::AutoDiffScalar::operator>=
bool operator>=(const AutoDiffScalar< OtherDerType > &b) const
Definition: AutoDiffScalar.h:177
Eigen::AutoDiffScalar::m_value
Scalar m_value
Definition: AutoDiffScalar.h:378
Eigen::AutoDiffScalar::operator+
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
Eigen::AutoDiffScalar::operator<<
friend std::ostream & operator<<(std::ostream &s, const AutoDiffScalar &a)
Definition: AutoDiffScalar.h:119
Eigen::NumTraits< AutoDiffScalar< DerType > >::NonInteger
AutoDiffScalar< DerType > NonInteger
Definition: AutoDiffScalar.h:708
asin
const EIGEN_DEVICE_FUNC AsinReturnType asin() const
Definition: ArrayCwiseUnaryOps.h:311
exp
const EIGEN_DEVICE_FUNC ExpReturnType exp() const
Definition: ArrayCwiseUnaryOps.h:97
Eigen::NumTraits< AutoDiffScalar< DerType > >::DerTypeCleaned
internal::remove_all< DerType >::type DerTypeCleaned
Definition: AutoDiffScalar.h:705
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::AutoDiffScalar::operator+=
AutoDiffScalar & operator+=(const AutoDiffScalar< OtherDerType > &other)
Definition: AutoDiffScalar.h:219
ceres::acos
Jet< T, N > acos(const Jet< T, N > &f)
Definition: jet.h:432
Eigen::MakeAutoDiffScalar
AutoDiffScalar< NewDerType > MakeAutoDiffScalar(const typename NewDerType::Scalar &value, const NewDerType &der)
Definition: AutoDiffScalar.h:36
Eigen::AutoDiffScalar::operator-
const AutoDiffScalar< DerType & > operator-(const Scalar &b) const
Definition: AutoDiffScalar.h:225
Eigen::AutoDiffScalar::operator!=
friend bool operator!=(const Scalar &a, const AutoDiffScalar &b)
Definition: AutoDiffScalar.h:172
ceres::cos
Jet< T, N > cos(const Jet< T, N > &f)
Definition: jet.h:426
Eigen::AutoDiffScalar::operator>
bool operator>(const Scalar &other) const
Definition: AutoDiffScalar.h:162
Eigen::AutoDiffScalar::operator<=
bool operator<=(const AutoDiffScalar< OtherDerType > &b) const
Definition: AutoDiffScalar.h:175
Eigen::CwiseNullaryOp
Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:60
Eigen::AutoDiffScalar::operator=
AutoDiffScalar & operator=(const Scalar &other)
Definition: AutoDiffScalar.h:143
cosh
const EIGEN_DEVICE_FUNC CoshReturnType cosh() const
Definition: ArrayCwiseUnaryOps.h:353
Eigen::AutoDiffScalar::operator+
const AutoDiffScalar< DerType & > operator+(const Scalar &other) const
Definition: AutoDiffScalar.h:181
Eigen::AutoDiffScalar::operator/
const friend AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DerType, Scalar, product) > operator/(const Scalar &other, const AutoDiffScalar &a)
Definition: AutoDiffScalar.h:304
Eigen::internal::is_convertible
Definition: Meta.h:257
Eigen::AutoDiffScalar::operator==
bool operator==(const AutoDiffScalar< OtherDerType > &b) const
Definition: AutoDiffScalar.h:178
Eigen::AutoDiffScalar::operator-=
AutoDiffScalar & operator-=(const AutoDiffScalar< OtherDerType > &other)
Definition: AutoDiffScalar.h:255
Eigen::expx
Scalar expx
Definition: AutoDiffScalar.h:634
Eigen::internal::auto_diff_special_op< DerivativeType, true >::DerType
remove_all< DerivativeType >::type DerType
Definition: AutoDiffScalar.h:390
Type
Definition: typing.h:67
A
Definition: test_numpy_dtypes.cpp:298
Eigen::internal::make_coherent_expression
void make_coherent_expression(CwiseBinaryOp< BinOp, A, B > xpr, const RefType &ref)
Definition: AutoDiffScalar.h:457
Eigen::internal::auto_diff_special_op< DerivativeType, true >::operator+
const friend AutoDiffScalar< DerType & > operator+(const Real &a, const AutoDiffScalar< DerivativeType > &b)
Definition: AutoDiffScalar.h:413
Eigen::CwiseUnaryOp::nestedExpression
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE internal::remove_all< XprTypeNested >::type & nestedExpression() const
Definition: CwiseUnaryOp.h:80
Eigen::AutoDiffScalar::value
const Scalar & value() const
Definition: AutoDiffScalar.h:154
Eigen::AutoDiffScalar::AutoDiffScalar
AutoDiffScalar(const Real &value)
Definition: AutoDiffScalar.h:96
Eigen::AutoDiffScalar::AutoDiffScalar
AutoDiffScalar(const Scalar &value, const DerType &der)
Definition: AutoDiffScalar.h:104
Eigen::Dynamic
const int Dynamic
Definition: Constants.h:22
Eigen::AutoDiffScalar::operator-
const friend AutoDiffScalar< CwiseUnaryOp< internal::scalar_opposite_op< Scalar >, const DerType > > operator-(const Scalar &a, const AutoDiffScalar &b)
Definition: AutoDiffScalar.h:231
Eigen::CleanedUpDerType::type
AutoDiffScalar< typename Eigen::internal::remove_all< DerType >::type::PlainObject > type
Definition: AutoDiffScalar.h:570
Eigen::internal::scalar_difference_op
Definition: BinaryFunctors.h:349
Eigen::AutoDiffScalar::operator-=
AutoDiffScalar & operator-=(const Scalar &other)
Definition: AutoDiffScalar.h:237
Eigen::NumTraits< AutoDiffScalar< DerType > >::Literal
NumTraits< typename DerTypeCleaned::Scalar >::Literal Literal
Definition: AutoDiffScalar.h:710
Eigen::AutoDiffScalar::value
Scalar & value()
Definition: AutoDiffScalar.h:155
Eigen::AutoDiffScalar::Base
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
Eigen::Triplet< double >
Eigen::AutoDiffScalar::operator<
bool operator<(const Scalar &other) const
Definition: AutoDiffScalar.h:160
tan
const EIGEN_DEVICE_FUNC TanReturnType tan() const
Definition: ArrayCwiseUnaryOps.h:269
ceres::pow
Jet< T, N > pow(const Jet< T, N > &f, double g)
Definition: jet.h:570
EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE
#define EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(EXPR, SCALAR, OPNAME)
Definition: Macros.h:1347
Eigen::AutoDiffScalar::operator*
const friend AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DerType, Scalar, product) > operator*(const Scalar &other, const AutoDiffScalar &a)
Definition: AutoDiffScalar.h:276
Eigen::internal::operator*
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorUInt128< uint64_t, uint64_t > operator*(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
Definition: TensorUInt128.h:136
Eigen::CwiseBinaryOp::rhs
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE _RhsNested & rhs() const
Definition: CwiseBinaryOp.h:135
Eigen::AutoDiffScalar::operator!=
bool operator!=(const AutoDiffScalar< OtherDerType > &b) const
Definition: AutoDiffScalar.h:179
y
Scalar * y
Definition: level1_cplx_impl.h:124
Eigen::AutoDiffScalar::operator==
friend bool operator==(const Scalar &a, const AutoDiffScalar &b)
Definition: AutoDiffScalar.h:171
atan2
AnnoyingScalar atan2(const AnnoyingScalar &y, const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:110
Eigen::EIGEN_AUTODIFF_DECLARE_GLOBAL_UNARY
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
Eigen::AutoDiffScalar::operator*
const AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DerType, Scalar, product) > operator*(const Scalar &other) const
Definition: AutoDiffScalar.h:270
Eigen::AutoDiffScalar::operator>=
bool operator>=(const Scalar &other) const
Definition: AutoDiffScalar.h:163
Eigen::AutoDiffScalar::operator*=
AutoDiffScalar & operator*=(const Scalar &other)
Definition: AutoDiffScalar.h:351
Eigen::internal::operator-
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TensorUInt128< uint64_t, uint64_t > operator-(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
Definition: TensorUInt128.h:124
Eigen::internal::auto_diff_special_op
Definition: AutoDiffScalar.h:29
Eigen::real
const AutoDiffScalar< DerType > & real(const AutoDiffScalar< DerType > &x)
Definition: AutoDiffScalar.h:576
Eigen::AutoDiffScalar::DerType
internal::remove_all< DerivativeType >::type DerType
Definition: AutoDiffScalar.h:76
Eigen::internal::auto_diff_special_op< DerivativeType, true >::operator*
const AutoDiffScalar< typename CwiseUnaryOp< bind2nd_op< scalar_product_op< Scalar, Real > >, DerType >::Type > operator*(const Real &other) const
Definition: AutoDiffScalar.h:426
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
Eigen::AutoDiffScalar::operator+
const friend AutoDiffScalar< DerType & > operator+(const Scalar &a, const AutoDiffScalar &b)
Definition: AutoDiffScalar.h:186
Eigen::AutoDiffScalar::AutoDiffScalar
AutoDiffScalar()
Definition: AutoDiffScalar.h:84
Eigen::numext::abs2
EIGEN_DEVICE_FUNC bool abs2(bool x)
Definition: Eigen/src/Core/MathFunctions.h:1294
Eigen::AutoDiffScalar::AutoDiffScalar
AutoDiffScalar(const Scalar &value, int nbDer, int derNumber)
Definition: AutoDiffScalar.h:88
tanh
const EIGEN_DEVICE_FUNC TanhReturnType tanh() const
Definition: ArrayCwiseUnaryOps.h:325
Eigen::internal::traits
Definition: ForwardDeclarations.h:17
Eigen::imag
DerType::Scalar imag(const AutoDiffScalar< DerType > &)
Definition: AutoDiffScalar.h:578
Eigen::AutoDiffScalar::operator=
AutoDiffScalar & operator=(const AutoDiffScalar &other)
Definition: AutoDiffScalar.h:136
Eigen::AutoDiffScalar::operator<=
friend bool operator<=(const Scalar &a, const AutoDiffScalar &b)
Definition: AutoDiffScalar.h:168
Eigen::internal::make_coherent_impl
Definition: AutoDiffScalar.h:18
Eigen::CwiseUnaryOp
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:55
std
Definition: BFloat16.h:88
Eigen::AutoDiffScalar::Real
NumTraits< Scalar >::Real Real
Definition: AutoDiffScalar.h:78
Eigen::internal::auto_diff_special_op< DerivativeType, true >::Scalar
traits< DerType >::Scalar Scalar
Definition: AutoDiffScalar.h:391
Eigen::internal::make_coherent
void make_coherent(const A &a, const B &b)
Definition: AutoDiffScalar.h:24
Eigen::internal::auto_diff_special_op< DerivativeType, true >::operator+
const AutoDiffScalar< DerType & > operator+(const Real &other) const
Definition: AutoDiffScalar.h:408
ref
Reference counting helper.
Definition: object.h:67
Eigen::ScalarBinaryOpTraits< AutoDiffScalar< DerType >, typename DerType::Scalar, BinOp >::ReturnType
AutoDiffScalar< DerType > ReturnType
Definition: AutoDiffScalar.h:531
Eigen::AutoDiffScalar::operator*=
AutoDiffScalar & operator*=(const AutoDiffScalar< OtherDerType > &other)
Definition: AutoDiffScalar.h:358
Eigen::AutoDiffScalar::AutoDiffScalar
AutoDiffScalar(const AutoDiffScalar &other)
Definition: AutoDiffScalar.h:124
product
void product(const MatrixType &m)
Definition: product.h:20
Eigen::NumTraits< AutoDiffScalar< DerType > >::Nested
AutoDiffScalar< DerType > Nested
Definition: AutoDiffScalar.h:709
Eigen::AutoDiffScalar::operator==
bool operator==(const Scalar &other) const
Definition: AutoDiffScalar.h:164
Eigen::internal::is_same
Definition: Meta.h:148
Eigen::internal::operator+
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TensorUInt128< uint64_t, uint64_t > operator+(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
Definition: TensorUInt128.h:113
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition: 3rdparty/Eigen/Eigen/src/Core/Matrix.h:178
Eigen::AutoDiffScalar::operator/
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
abs
#define abs(x)
Definition: datatypes.h:17
internal
Definition: BandTriangularSolver.h:13
Eigen::min
CleanedUpDerType< DerType >::type() min(const AutoDiffScalar< DerType > &x, const T &y)
Definition: AutoDiffScalar.h:580
Eigen::AutoDiffScalar::operator/
const AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DerType, Scalar, product) > operator/(const Scalar &other) const
Definition: AutoDiffScalar.h:298
Eigen::internal::enable_if
Definition: Meta.h:273
Eigen::AutoDiffScalar::m_derivatives
DerType m_derivatives
Definition: AutoDiffScalar.h:379
Eigen::internal::make_coherent_impl::run
static void run(A &, B &)
Definition: AutoDiffScalar.h:19
sinh
const EIGEN_DEVICE_FUNC SinhReturnType sinh() const
Definition: ArrayCwiseUnaryOps.h:339
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
Eigen::AutoDiffScalar::operator/=
AutoDiffScalar & operator/=(const AutoDiffScalar< OtherDerType > &other)
Definition: AutoDiffScalar.h:371
Eigen::internal::make_coherent_impl< A, 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:492
Eigen::NumTraits
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:232
test_callbacks.value
value
Definition: test_callbacks.py:160
ceres::sqrt
Jet< T, N > sqrt(const Jet< T, N > &f)
Definition: jet.h:418
Eigen::ScalarBinaryOpTraits< typename DerType::Scalar, AutoDiffScalar< DerType >, BinOp >::ReturnType
AutoDiffScalar< DerType > ReturnType
Definition: AutoDiffScalar.h:537
Eigen::internal::auto_diff_special_op< DerivativeType, true >::operator*
const friend AutoDiffScalar< typename CwiseUnaryOp< bind1st_op< scalar_product_op< Real, Scalar > >, DerType >::Type > operator*(const Real &other, const AutoDiffScalar< DerivativeType > &a)
Definition: AutoDiffScalar.h:434
Eigen::internal::make_coherent_impl< A, Matrix< B_Scalar, B_Rows, B_Cols, B_Options, B_MaxRows, B_MaxCols > >::run
static void run(A &a, B &b)
Definition: AutoDiffScalar.h:493
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
Eigen::internal::auto_diff_special_op< DerivativeType, true >::operator+=
AutoDiffScalar< DerivativeType > & operator+=(const Real &other)
Definition: AutoDiffScalar.h:418
Eigen::AutoDiffScalar::operator>=
friend bool operator>=(const Scalar &a, const AutoDiffScalar &b)
Definition: AutoDiffScalar.h:170
Eigen::CwiseBinaryOp::lhs
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE _LhsNested & lhs() const
Definition: CwiseBinaryOp.h:132
Eigen::internal::make_coherent_impl< Matrix< A_Scalar, A_Rows, A_Cols, A_Options, A_MaxRows, A_MaxCols >, B >::run
static void run(A &a, B &b)
Definition: AutoDiffScalar.h:477
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46
EIGEN_COMMA
#define EIGEN_COMMA
Definition: Macros.h:904
Eigen::AutoDiffScalar::operator=
AutoDiffScalar & operator=(const AutoDiffScalar< OtherDerType > &other)
Definition: AutoDiffScalar.h:129


gtsam
Author(s):
autogenerated on Thu Dec 19 2024 04:00:43