157#ifndef G2O_CERES_PUBLIC_JET_H_
158#define G2O_CERES_PUBLIC_JET_H_
171template <
typename T,
int N>
184 explicit Jet(
const T& value) {
190 Jet(
const T& value,
int k) {
200 template <
typename Derived>
201 EIGEN_STRONG_INLINE
Jet(
const T&
a,
const Eigen::DenseBase<Derived>&
v)
250 Eigen::Matrix<T, N, 1>
v;
254 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
258template <
typename T,
int N>
267template <
typename T,
int N>
273template <
typename T,
int N>
279template <
typename T,
int N>
285template <
typename T,
int N>
291template <
typename T,
int N>
297template <
typename T,
int N>
303template <
typename T,
int N>
309template <
typename T,
int N>
315template <
typename T,
int N>
321template <
typename T,
int N>
327template <
typename T,
int N>
336 const T g_a_inverse = T(1.0) / g.
a;
337 const T f_a_by_g_a = f.
a * g_a_inverse;
338 return Jet<T, N>(f_a_by_g_a, (f.
v - f_a_by_g_a * g.
v) * g_a_inverse);
342template <
typename T,
int N>
344 const T minus_s_g_a_inverse2 = -s / (g.
a * g.
a);
345 return Jet<T, N>(s / g.
a, g.
v * minus_s_g_a_inverse2);
349template <
typename T,
int N>
351 const T s_inverse = T(1.0) / s;
352 return Jet<T, N>(f.
a * s_inverse, f.
v * s_inverse);
356#define G2O_CERES_DEFINE_JET_COMPARISON_OPERATOR(op) \
357 template <typename T, int N> \
358 inline bool operator op(const Jet<T, N>& f, const Jet<T, N>& g) { \
361 template <typename T, int N> \
362 inline bool operator op(const T& s, const Jet<T, N>& g) { \
365 template <typename T, int N> \
366 inline bool operator op(const Jet<T, N>& f, const T& s) { \
375#undef G2O_CERES_DEFINE_JET_COMPARISON_OPERATOR
414inline bool IsFinite(
double x) {
return std::isfinite(x); }
416inline bool IsNaN(
double x) {
return std::isnan(x); }
417inline bool IsNormal(
double x) {
return std::isnormal(x); }
423template <
typename T,
int N>
425 return (f.
a < T(0.0) ? -f : f);
429template <
typename T,
int N>
431 const T a_inverse = T(1.0) / f.
a;
436template <
typename T,
int N>
438 const T tmp =
exp(f.
a);
443template <
typename T,
int N>
445 const T tmp =
sqrt(f.
a);
446 const T two_a_inverse = T(1.0) / (T(2.0) * tmp);
451template <
typename T,
int N>
457template <
typename T,
int N>
459 const T tmp = -T(1.0) /
sqrt(T(1.0) - f.
a * f.
a);
464template <
typename T,
int N>
470template <
typename T,
int N>
472 const T tmp = T(1.0) /
sqrt(T(1.0) - f.
a * f.
a);
477template <
typename T,
int N>
479 const T tan_a =
tan(f.
a);
480 const T tmp = T(1.0) + tan_a * tan_a;
485template <
typename T,
int N>
487 const T tmp = T(1.0) / (T(1.0) + f.
a * f.
a);
492template <
typename T,
int N>
498template <
typename T,
int N>
504template <
typename T,
int N>
506 const T tanh_a =
tanh(f.
a);
507 const T tmp = T(1.0) - tanh_a * tanh_a;
515template <
typename T,
int N>
524template <
typename T,
int N>
532template <
typename T,
int N>
534 const T derivative = T(1.0) / (T(3.0) *
cbrt(f.
a * f.
a));
539template <
typename T,
int N>
541 const T tmp =
exp2(f.
a);
542 const T derivative = tmp *
log(T(2));
547template <
typename T,
int N>
549 const T derivative = T(1.0) / (f.
a *
log(T(2)));
557template <
typename T,
int N>
568template <
typename T,
int N>
570 return x < y ? y : x;
573template <
typename T,
int N>
575 return y < x ? y : x;
581template <
typename T,
int N>
588template <
typename T,
int N>
600#if defined(G2O_CERES_MSVC_USE_UNDERSCORE_PREFIXED_BESSEL_FUNCTIONS)
607#if defined(G2O_CERES_MSVC_USE_UNDERSCORE_PREFIXED_BESSEL_FUNCTIONS)
614#if defined(G2O_CERES_MSVC_USE_UNDERSCORE_PREFIXED_BESSEL_FUNCTIONS)
629template <
typename T,
int N>
636template <
typename T,
int N>
644template <
typename T,
int N>
662template <
typename T,
int N>
667 for (
int i = 0; i < N; ++i) {
674template <
typename T,
int N>
677 for (
int i = 0; i < N; ++i) {
678 result = result |
isinf(f.
v[i]);
684template <
typename T,
int N>
687 for (
int i = 0; i < N; ++i) {
688 result = result |
isnan(f.
v[i]);
694template <
typename T,
int N>
697 for (
int i = 0; i < N; ++i) {
704template <
typename T,
int N>
709template <
typename T,
int N>
714template <
typename T,
int N>
720template <
typename T,
int N>
729template <
typename T,
int N>
736 T
const tmp = T(1.0) / (f.
a * f.
a + g.
a * g.
a);
742template <
typename T,
int N>
744 T
const tmp = g *
pow(f.
a, g - T(1.0));
759template <
typename T,
int N>
763 if (f == T(0) && g.
a > T(0)) {
767 if (f < 0 && g.
a ==
floor(g.
a)) {
769 for (
int i = 0; i < N; i++) {
770 if (g.
v[i] != T(0.0)) {
772 result.
v[i] = std::numeric_limits<T>::quiet_NaN();
777 T
const tmp =
pow(f, g.
a);
821template <
typename T,
int N>
825 if (f.
a == T(0) && g.
a >= T(1)) {
834 if (f.
a < T(0) && g.
a ==
floor(g.
a)) {
836 T
const tmp = g.
a *
pow(f.
a, g.
a - T(1.0));
838 for (
int i = 0; i < N; i++) {
839 if (g.
v[i] != T(0.0)) {
841 result.
v[i] = T(std::numeric_limits<double>::quiet_NaN());
848 T
const tmp1 =
pow(f.
a, g.
a);
849 T
const tmp2 = g.
a *
pow(f.
a, g.
a - T(1.0));
850 T
const tmp3 = tmp1 *
log(f.
a);
861template <
typename T,
int N>
863 s <<
"[" << z.
a <<
" ; ";
864 for (
int i = 0; i < N; ++i) {
878template <
typename T,
int N>
879struct numeric_limits<
g2o::ceres::Jet<T, N>> {
880 static constexpr bool is_specialized =
true;
881 static constexpr bool is_signed = std::numeric_limits<T>::is_signed;
882 static constexpr bool is_integer = std::numeric_limits<T>::is_integer;
883 static constexpr bool is_exact = std::numeric_limits<T>::is_exact;
884 static constexpr bool has_infinity = std::numeric_limits<T>::has_infinity;
885 static constexpr bool has_quiet_NaN = std::numeric_limits<T>::has_quiet_NaN;
886 static constexpr bool has_signaling_NaN = std::numeric_limits<T>::has_signaling_NaN;
887 static constexpr bool is_iec559 = std::numeric_limits<T>::is_iec559;
888 static constexpr bool is_bounded = std::numeric_limits<T>::is_bounded;
889 static constexpr bool is_modulo = std::numeric_limits<T>::is_modulo;
891 static constexpr std::float_denorm_style has_denorm = std::numeric_limits<T>::has_denorm;
892 static constexpr std::float_round_style round_style = std::numeric_limits<T>::round_style;
894 static constexpr int digits = std::numeric_limits<T>::digits;
895 static constexpr int digits10 = std::numeric_limits<T>::digits10;
896 static constexpr int max_digits10 = std::numeric_limits<T>::max_digits10;
897 static constexpr int radix = std::numeric_limits<T>::radix;
898 static constexpr int min_exponent = std::numeric_limits<T>::min_exponent;
899 static constexpr int min_exponent10 = std::numeric_limits<T>::max_exponent10;
900 static constexpr int max_exponent = std::numeric_limits<T>::max_exponent;
901 static constexpr int max_exponent10 = std::numeric_limits<T>::max_exponent10;
902 static constexpr bool traps = std::numeric_limits<T>::traps;
903 static constexpr bool tinyness_before = std::numeric_limits<T>::tinyness_before;
942template <
typename T,
int N>
943struct NumTraits<
g2o::ceres::Jet<T, N>> {
954 return Real(std::numeric_limits<T>::epsilon());
957 static inline int digits10() {
return NumTraits<T>::digits10(); }
967 HasFloatingPoint = 1,
968 RequireInitialization = 1
971 template <
bool Vectorized>
974#if defined(EIGEN_VECTORIZE_AVX)
996template <
typename BinaryOp,
typename T,
int N>
997struct ScalarBinaryOpTraits<
g2o::ceres::Jet<T, N>, T, BinaryOp> {
1000template <
typename BinaryOp,
typename T,
int N>
1001struct ScalarBinaryOpTraits<T,
g2o::ceres::Jet<T, N>, BinaryOp> {
#define G2O_CERES_DEFINE_JET_COMPARISON_OPERATOR(op)
Jet< T, N > cosh(const Jet< T, N > &f)
Jet< T, N > pow(const Jet< T, N > &f, double g)
bool isnormal(const Jet< T, N > &f)
Jet< T, N > fmax(const Jet< T, N > &x, const Jet< T, N > &y)
Jet< T, N > operator/(const Jet< T, N > &f, const Jet< T, N > &g)
Jet< T, N > tan(const Jet< T, N > &f)
Jet< T, N > cos(const Jet< T, N > &f)
Jet< T, N > erf(const Jet< T, N > &x)
Jet< T, N > sin(const Jet< T, N > &f)
Jet< T, N > operator*(const Jet< T, N > &f, const Jet< T, N > &g)
bool isfinite(const Jet< T, N > &f)
Jet< T, N > sinh(const Jet< T, N > &f)
Jet< T, N > floor(const Jet< T, N > &f)
Jet< T, N > sqrt(const Jet< T, N > &f)
Jet< T, N > atan2(const Jet< T, N > &g, const Jet< T, N > &f)
double BesselJ1(double x)
Jet< T, N > log(const Jet< T, N > &f)
Jet< T, N > hypot(const Jet< T, N > &x, const Jet< T, N > &y)
double BesselJ0(double x)
Jet< T, N > ceil(const Jet< T, N > &f)
Jet< T, N > exp(const Jet< T, N > &f)
Jet< T, N > exp2(const Jet< T, N > &f)
Jet< T, N > log2(const Jet< T, N > &f)
std::ostream & operator<<(std::ostream &s, const Jet< T, N > &z)
Jet< T, N > const & operator+(const Jet< T, N > &f)
Jet< T, N > tanh(const Jet< T, N > &f)
Jet< T, N > atan(const Jet< T, N > &f)
Jet< T, N > abs(const Jet< T, N > &f)
bool isnan(const Jet< T, N > &f)
Jet< T, N > operator-(const Jet< T, N > &f)
bool IsInfinite(double x)
Jet< T, N > cbrt(const Jet< T, N > &f)
Jet< T, N > acos(const Jet< T, N > &f)
Jet< T, N > erfc(const Jet< T, N > &x)
bool isinf(const Jet< T, N > &f)
Jet< T, N > fmin(const Jet< T, N > &x, const Jet< T, N > &y)
Jet< T, N > asin(const Jet< T, N > &f)
double BesselJn(int n, double x)
static g2o::ceres::Jet< T, N > dummy_precision()
EIGEN_STRONG_INLINE Jet(const T &a, const Eigen::DenseBase< Derived > &v)
Jet< T, N > & operator/=(const T &s)
Jet< T, N > & operator*=(const T &s)
Jet< T, N > & operator+=(const Jet< T, N > &y)
Jet< T, N > & operator/=(const Jet< T, N > &y)
Jet< T, N > & operator-=(const Jet< T, N > &y)
Jet< T, N > & operator-=(const T &s)
Eigen::Matrix< T, N, 1 > v
Jet< T, N > & operator*=(const Jet< T, N > &y)
Jet(const T &value, int k)
Jet< T, N > & operator+=(const T &s)
static constexpr g2o::ceres::Jet< T, N > lowest() noexcept
static constexpr g2o::ceres::Jet< T, N > epsilon() noexcept
static constexpr g2o::ceres::Jet< T, N > denorm_min() noexcept
static constexpr g2o::ceres::Jet< T, N > max() noexcept
static constexpr g2o::ceres::Jet< T, N > signaling_NaN() noexcept
static constexpr g2o::ceres::Jet< T, N > infinity() noexcept
static constexpr g2o::ceres::Jet< T, N > quiet_NaN() noexcept
static constexpr g2o::ceres::Jet< T, N > min() noexcept
static constexpr g2o::ceres::Jet< T, N > round_error() noexcept