~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to extern/libmv/third_party/ceres/include/ceres/jet.h

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-02-19 11:24:23 UTC
  • mfrom: (14.2.23 sid)
  • Revision ID: package-import@ubuntu.com-20140219112423-rkmaz2m7ha06d4tk
Tags: 2.69-3ubuntu1
* Merge with Debian; remaining changes:
  - Configure without OpenImageIO on armhf, as it is not available on
    Ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
405
405
// double-valued and Jet-valued functions, but we are not allowed to put
406
406
// Jet-valued functions inside namespace std.
407
407
//
408
 
// Missing: cosh, sinh, tanh, tan
409
408
// TODO(keir): Switch to "using".
410
409
inline double abs     (double x) { return std::abs(x);      }
411
410
inline double log     (double x) { return std::log(x);      }
415
414
inline double acos    (double x) { return std::acos(x);     }
416
415
inline double sin     (double x) { return std::sin(x);      }
417
416
inline double asin    (double x) { return std::asin(x);     }
 
417
inline double tan     (double x) { return std::tan(x);      }
 
418
inline double atan    (double x) { return std::atan(x);     }
 
419
inline double sinh    (double x) { return std::sinh(x);     }
 
420
inline double cosh    (double x) { return std::cosh(x);     }
 
421
inline double tanh    (double x) { return std::tanh(x);     }
418
422
inline double pow  (double x, double y) { return std::pow(x, y);   }
419
423
inline double atan2(double y, double x) { return std::atan2(y, x); }
420
424
 
495
499
  return g;
496
500
}
497
501
 
 
502
// tan(a + h) ~= tan(a) + (1 + tan(a)^2) h
 
503
template <typename T, int N> inline
 
504
Jet<T, N> tan(const Jet<T, N>& f) {
 
505
  Jet<T, N> g;
 
506
  g.a = tan(f.a);
 
507
  double tan_a = tan(f.a);
 
508
  const T tmp = T(1.0) + tan_a * tan_a;
 
509
  g.v = tmp * f.v;
 
510
  return g;
 
511
}
 
512
 
 
513
// atan(a + h) ~= atan(a) + 1 / (1 + a^2) h
 
514
template <typename T, int N> inline
 
515
Jet<T, N> atan(const Jet<T, N>& f) {
 
516
  Jet<T, N> g;
 
517
  g.a = atan(f.a);
 
518
  const T tmp = T(1.0) / (T(1.0) + f.a * f.a);
 
519
  g.v = tmp * f.v;
 
520
  return g;
 
521
}
 
522
 
 
523
// sinh(a + h) ~= sinh(a) + cosh(a) h
 
524
template <typename T, int N> inline
 
525
Jet<T, N> sinh(const Jet<T, N>& f) {
 
526
  Jet<T, N> g;
 
527
  g.a = sinh(f.a);
 
528
  const T cosh_a = cosh(f.a);
 
529
  g.v = cosh_a * f.v;
 
530
  return g;
 
531
}
 
532
 
 
533
// cosh(a + h) ~= cosh(a) + sinh(a) h
 
534
template <typename T, int N> inline
 
535
Jet<T, N> cosh(const Jet<T, N>& f) {
 
536
  Jet<T, N> g;
 
537
  g.a = cosh(f.a);
 
538
  const T sinh_a = sinh(f.a);
 
539
  g.v = sinh_a * f.v;
 
540
  return g;
 
541
}
 
542
 
 
543
// tanh(a + h) ~= tanh(a) + (1 - tanh(a)^2) h
 
544
template <typename T, int N> inline
 
545
Jet<T, N> tanh(const Jet<T, N>& f) {
 
546
  Jet<T, N> g;
 
547
  g.a = tanh(f.a);
 
548
  double tanh_a = tanh(f.a);
 
549
  const T tmp = T(1.0) - tanh_a * tanh_a;
 
550
  g.v = tmp * f.v;
 
551
  return g;
 
552
}
 
553
 
498
554
// Jet Classification. It is not clear what the appropriate semantics are for
499
555
// these classifications. This picks that IsFinite and isnormal are "all"
500
556
// operations, i.e. all elements of the jet must be finite for the jet itself
645
701
template<typename T, int N> inline       Jet<T, N>  ei_log (const Jet<T, N>& x) { return log(x);         }  // NOLINT
646
702
template<typename T, int N> inline       Jet<T, N>  ei_sin (const Jet<T, N>& x) { return sin(x);         }  // NOLINT
647
703
template<typename T, int N> inline       Jet<T, N>  ei_cos (const Jet<T, N>& x) { return cos(x);         }  // NOLINT
 
704
template<typename T, int N> inline       Jet<T, N>  ei_tan (const Jet<T, N>& x) { return tan(x);         }  // NOLINT
 
705
template<typename T, int N> inline       Jet<T, N>  ei_atan(const Jet<T, N>& x) { return atan(x);        }  // NOLINT
 
706
template<typename T, int N> inline       Jet<T, N>  ei_sinh(const Jet<T, N>& x) { return sinh(x);        }  // NOLINT
 
707
template<typename T, int N> inline       Jet<T, N>  ei_cosh(const Jet<T, N>& x) { return cosh(x);        }  // NOLINT
 
708
template<typename T, int N> inline       Jet<T, N>  ei_tanh(const Jet<T, N>& x) { return tanh(x);        }  // NOLINT
648
709
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
649
710
 
650
711
// Note: This has to be in the ceres namespace for argument dependent lookup to