Lines Matching defs:Jet
65 // the function with one extended with infinitesimals. The class Jet, defined in
96 // this file, it is necessary to create a single jet type which has components
105 // Jet<double, 2> x(0); // Pick the 0th dual number for x.
106 // Jet<double, 2> y(1); // Pick the 1st dual number for y.
107 // Jet<double, 2> z = f(x, y);
112 // Most users should not use Jet objects directly; a wrapper around Jet objects,
118 // "jets". A 1st order jet is an element of the ring
122 // which essentially means that each jet consists of a "scalar" value 'a' from T
138 // The only remaining question is how to evaluate the function of a jet, for
170 struct Jet {
175 // (where T is a Jet<T, N>). This usually only happens in opt mode. Note that
178 Jet() : a() {
183 explicit Jet(const T& value) {
189 Jet(const T& value, int k) {
200 Jet(const T& value, const Eigen::DenseBase<Derived> &vIn)
207 Jet<T, N>& operator+=(const Jet<T, N> &y) {
212 Jet<T, N>& operator-=(const Jet<T, N> &y) {
217 Jet<T, N>& operator*=(const Jet<T, N> &y) {
222 Jet<T, N>& operator/=(const Jet<T, N> &y) {
250 Jet<T, N> const& operator+(const Jet<T, N>& f) {
259 Jet<T, N> operator-(const Jet<T, N>&f) {
260 return Jet<T, N>(-f.a, -f.v);
265 Jet<T, N> operator+(const Jet<T, N>& f,
266 const Jet<T, N>& g) {
267 return Jet<T, N>(f.a + g.a, f.v + g.v);
272 Jet<T, N> operator+(const Jet<T, N>& f, T s) {
273 return Jet<T, N>(f.a + s, f.v);
278 Jet<T, N> operator+(T s, const Jet<T, N>& f) {
279 return Jet<T, N>(f.a + s, f.v);
284 Jet<T, N> operator-(const Jet<T, N>& f,
285 const Jet<T, N>& g) {
286 return Jet<T, N>(f.a - g.a, f.v - g.v);
291 Jet<T, N> operator-(const Jet<T, N>& f, T s) {
292 return Jet<T, N>(f.a - s, f.v);
297 Jet<T, N> operator-(T s, const Jet<T, N>& f) {
298 return Jet<T, N>(s - f.a, -f.v);
303 Jet<T, N> operator*(const Jet<T, N>& f,
304 const Jet<T, N>& g) {
305 return Jet<T, N>(f.a * g.a, f.a * g.v + f.v * g.a);
310 Jet<T, N> operator*(const Jet<T, N>& f, T s) {
311 return Jet<T, N>(f.a * s, f.v * s);
316 Jet<T, N> operator*(T s, const Jet<T, N>& f) {
317 return Jet<T, N>(f.a * s, f.v * s);
322 Jet<T, N> operator/(const Jet<T, N>& f,
323 const Jet<T, N>& g) {
333 return Jet<T, N>(f.a * g_a_inverse, (f.v - f_a_by_g_a * g.v) * g_a_inverse);
338 Jet<T, N> operator/(T s, const Jet<T, N>& g) {
340 return Jet<T, N>(s / g.a, g.v * minus_s_g_a_inverse2);
345 Jet<T, N> operator/(const Jet<T, N>& f, T s) {
347 return Jet<T, N>(f.a * s_inverse, f.v * s_inverse);
353 bool operator op(const Jet<T, N>& f, const Jet<T, N>& g) { \
357 bool operator op(const T& s, const Jet<T, N>& g) { \
361 bool operator op(const Jet<T, N>& f, const T& s) { \
375 // double-valued and Jet-valued functions, but we are not allowed to put
376 // Jet-valued functions inside namespace std.
399 Jet<T, N> abs(const Jet<T, N>& f) {
405 Jet<T, N> log(const Jet<T, N>& f) {
407 return Jet<T, N>(log(f.a), f.v * a_inverse);
412 Jet<T, N> exp(const Jet<T, N>& f) {
414 return Jet<T, N>(tmp, tmp * f.v);
419 Jet<T, N> sqrt(const Jet<T, N>& f) {
422 return Jet<T, N>(tmp, f.v * two_a_inverse);
427 Jet<T, N> cos(const Jet<T, N>& f) {
428 return Jet<T, N>(cos(f.a), - sin(f.a) * f.v);
433 Jet<T, N> acos(const Jet<T, N>& f) {
435 return Jet<T, N>(acos(f.a), tmp * f.v);
440 Jet<T, N> sin(const Jet<T, N>& f) {
441 return Jet<T, N>(sin(f.a), cos(f.a) * f.v);
446 Jet<T, N> asin(const Jet<T, N>& f) {
448 return Jet<T, N>(asin(f.a), tmp * f.v);
453 Jet<T, N> tan(const Jet<T, N>& f) {
456 return Jet<T, N>(tan_a, tmp * f.v);
461 Jet<T, N> atan(const Jet<T, N>& f) {
463 return Jet<T, N>(atan(f.a), tmp * f.v);
468 Jet<T, N> sinh(const Jet<T, N>& f) {
469 return Jet<T, N>(sinh(f.a), cosh(f.a) * f.v);
474 Jet<T, N> cosh(const Jet<T, N>& f) {
475 return Jet<T, N>(cosh(f.a), sinh(f.a) * f.v);
480 Jet<T, N> tanh(const Jet<T, N>& f) {
483 return Jet<T, N>(tanh_a, tmp * f.v);
486 // Jet Classification. It is not clear what the appropriate semantics are for
488 // operations, i.e. all elements of the jet must be finite for the jet itself
491 // part of a jet is nan or inf, then the entire jet is nan or inf. This leads
492 // to strange situations like a jet can be both IsInfinite and IsNaN, but in
496 // The jet is finite if all parts of the jet are finite.
498 bool IsFinite(const Jet<T, N>& f) {
510 // The jet is infinite if any part of the jet is infinite.
512 bool IsInfinite(const Jet<T, N>& f) {
524 // The jet is NaN if any part of the jet is NaN.
526 bool IsNaN(const Jet<T, N>& f) {
538 // The jet is normal if all parts of the jet are normal.
540 bool IsNormal(const Jet<T, N>& f) {
557 Jet<T, N> atan2(const Jet<T, N>& g, const Jet<T, N>& f) {
564 return Jet<T, N>(atan2(g.a, f.a), tmp * (- g.a * f.v + f.a * g.v));
571 Jet<T, N> pow(const Jet<T, N>& f, double g) {
573 return Jet<T, N>(pow(f.a, g), tmp * f.v);
579 Jet<T, N> pow(double f, const Jet<T, N>& g) {
581 return Jet<T, N>(tmp, log(f) * tmp * g.v);
588 Jet<T, N> pow(const Jet<T, N>& f, const Jet<T, N>& g) {
593 return Jet<T, N>(tmp1, tmp2 * f.v + tmp3 * g.v);
596 // Define the helper functions Eigen needs to embed Jet types.
600 // Among other things, this means that decompositions of Jet's does not work,
603 // Matrix<Jet<T, N> ... > A, x, b;
611 template<typename T, int N> inline const Jet<T, N>& ei_conj(const Jet<T, N>& x) { return x; } // NOLINT
612 template<typename T, int N> inline const Jet<T, N>& ei_real(const Jet<T, N>& x) { return x; } // NOLINT
613 template<typename T, int N> inline Jet<T, N> ei_imag(const Jet<T, N>& ) { return Jet<T, N>(0.0); } // NOLINT
614 template<typename T, int N> inline Jet<T, N> ei_abs (const Jet<T, N>& x) { return fabs(x); } // NOLINT
615 template<typename T, int N> inline Jet<T, N> ei_abs2(const Jet<T, N>& x) { return x * x; } // NOLINT
616 template<typename T, int N> inline Jet<T, N> ei_sqrt(const Jet<T, N>& x) { return sqrt(x); } // NOLINT
617 template<typename T, int N> inline Jet<T, N> ei_exp (const Jet<T, N>& x) { return exp(x); } // NOLINT
618 template<typename T, int N> inline Jet<T, N> ei_log (const Jet<T, N>& x) { return log(x); } // NOLINT
619 template<typename T, int N> inline Jet<T, N> ei_sin (const Jet<T, N>& x) { return sin(x); } // NOLINT
620 template<typename T, int N> inline Jet<T, N> ei_cos (const Jet<T, N>& x) { return cos(x); } // NOLINT
621 template<typename T, int N> inline Jet<T, N> ei_tan (const Jet<T, N>& x) { return tan(x); } // NOLINT
622 template<typename T, int N> inline Jet<T, N> ei_atan(const Jet<T, N>& x) { return atan(x); } // NOLINT
623 template<typename T, int N> inline Jet<T, N> ei_sinh(const Jet<T, N>& x) { return sinh(x); } // NOLINT
624 template<typename T, int N> inline Jet<T, N> ei_cosh(const Jet<T, N>& x) { return cosh(x); } // NOLINT
625 template<typename T, int N> inline Jet<T, N> ei_tanh(const Jet<T, N>& x) { return tanh(x); } // NOLINT
626 template<typename T, int N> inline Jet<T, N> ei_pow (const Jet<T, N>& x, Jet<T, N> y) { return pow(x, y); } // NOLINT
632 inline std::ostream &operator<<(std::ostream &s, const Jet<T, N>& z) {
640 // Creating a specialization of NumTraits enables placing Jet objects inside
643 struct NumTraits<ceres::Jet<T, N> > {
644 typedef ceres::Jet<T, N> Real;
645 typedef ceres::Jet<T, N> NonInteger;
646 typedef ceres::Jet<T, N> Nested;
648 static typename ceres::Jet<T, N> dummy_precision() {
649 return ceres::Jet<T, N>(1e-12);
660 // For Jet types, multiplication is more expensive than addition.