405
405
// double-valued and Jet-valued functions, but we are not allowed to put
406
406
// Jet-valued functions inside namespace std.
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); }
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) {
507
double tan_a = tan(f.a);
508
const T tmp = T(1.0) + tan_a * tan_a;
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) {
518
const T tmp = T(1.0) / (T(1.0) + f.a * f.a);
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) {
528
const T cosh_a = cosh(f.a);
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) {
538
const T sinh_a = sinh(f.a);
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) {
548
double tanh_a = tanh(f.a);
549
const T tmp = T(1.0) - tanh_a * tanh_a;
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
650
711
// Note: This has to be in the ceres namespace for argument dependent lookup to