[wpimath] Update to gcem 1.17.0 (#5575)

This commit is contained in:
Tyler Veness
2023-08-28 15:03:06 -07:00
committed by GitHub
parent cf86af7166
commit 0d2d989e84
66 changed files with 163 additions and 86 deletions

View File

@@ -13,7 +13,7 @@ from upstream_utils import (
def main():
upstream_root = clone_repo("https://github.com/kthohr/gcem.git", "v1.16.0")
upstream_root = clone_repo("https://github.com/kthohr/gcem.git", "v1.17.0")
wpilib_root = get_repo_root()
wpimath = os.path.join(wpilib_root, "wpimath")

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##
@@ -28,6 +28,30 @@
namespace internal
{
// see https://en.wikipedia.org/wiki/Euler%27s_continued_fraction_formula
#if __cplusplus >= 201402L // C++14 version
template<typename T>
constexpr
T
exp_cf_recur(const T x, const int depth_end)
noexcept
{
int depth = GCEM_EXP_MAX_ITER_SMALL - 1;
T res = T(1);
while (depth > depth_end - 1) {
res = T(1) + x/T(depth - 1) - x/depth/res;
--depth;
}
return res;
}
#else // C++11 version
template<typename T>
constexpr
T
@@ -36,20 +60,20 @@ noexcept
{
return( depth < GCEM_EXP_MAX_ITER_SMALL ? \
// if
depth == 1 ? \
T(1) - x/exp_cf_recur(x,depth+1) :
T(1) + x/T(depth - 1) - x/depth/exp_cf_recur(x,depth+1) :
T(1) + x/T(depth - 1) - x/depth/exp_cf_recur(x,depth+1) :
// else
T(1) );
}
#endif
template<typename T>
constexpr
T
exp_cf(const T x)
noexcept
{
return( T(1)/exp_cf_recur(x,1) );
return( T(1) / (T(1) - x / exp_cf_recur(x,2)) );
}
template<typename T>
@@ -72,7 +96,7 @@ noexcept
//
is_neginf(x) ? \
T(0) :
//
// indistinguishable from zero
GCLIM<T>::min() > abs(x) ? \
T(1) :
//

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##
@@ -34,10 +34,20 @@ llint_t
find_exponent(const T x, const llint_t exponent)
noexcept
{
return( x < T(1) ? \
find_exponent(x*T(10),exponent - llint_t(1)) :
return( // < 1
x < T(1e-03) ? \
find_exponent(x * T(1e+04), exponent - llint_t(4)) :
x < T(1e-01) ? \
find_exponent(x * T(1e+02), exponent - llint_t(2)) :
x < T(1) ? \
find_exponent(x * T(10), exponent - llint_t(1)) :
// > 10
x > T(10) ? \
find_exponent(x/T(10),exponent + llint_t(1)) :
find_exponent(x / T(10), exponent + llint_t(1)) :
x > T(1e+02) ? \
find_exponent(x / T(1e+02), exponent + llint_t(2)) :
x > T(1e+04) ? \
find_exponent(x / T(1e+04), exponent + llint_t(4)) :
// else
exponent );
}

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##
@@ -53,7 +53,7 @@
#endif
#ifndef GCEM_VERSION_MINOR
#define GCEM_VERSION_MINOR 16
#define GCEM_VERSION_MINOR 17
#endif
#ifndef GCEM_VERSION_PATCH

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##
@@ -31,6 +31,28 @@ namespace internal
// continued fraction seems to be a better approximation for small x
// see http://functions.wolfram.com/ElementaryFunctions/Log/10/0005/
#if __cplusplus >= 201402L // C++14 version
template<typename T>
constexpr
T
log_cf_main(const T xx, const int depth_end)
noexcept
{
int depth = GCEM_LOG_MAX_ITER_SMALL - 1;
T res = T(2*(depth+1) - 1);
while (depth > depth_end - 1) {
res = T(2*depth - 1) - T(depth*depth) * xx / res;
--depth;
}
return res;
}
#else // C++11 version
template<typename T>
constexpr
T
@@ -39,11 +61,13 @@ noexcept
{
return( depth < GCEM_LOG_MAX_ITER_SMALL ? \
// if
T(2*depth - 1) - T(depth*depth)*xx/log_cf_main(xx,depth+1) :
T(2*depth - 1) - T(depth*depth) * xx / log_cf_main(xx,depth+1) :
// else
T(2*depth - 1) );
}
#endif
template<typename T>
constexpr
T

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##
@@ -35,9 +35,9 @@ mantissa(const T x)
noexcept
{
return( x < T(1) ? \
mantissa(x*T(10)) :
mantissa(x * T(10)) :
x > T(10) ? \
mantissa(x/T(10)) :
mantissa(x / T(10)) :
// else
x );
}

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##
@@ -37,16 +37,37 @@ noexcept
return( abs(xn - x/xn) / (T(1) + xn) < GCLIM<T>::min() ? \
// if
xn :
count < GCEM_SQRT_MAX_ITER ? \
// else
sqrt_recur(x, T(0.5)*(xn + x/xn), count+1) :
xn );
count < GCEM_SQRT_MAX_ITER ? \
// if
sqrt_recur(x, T(0.5)*(xn + x/xn), count+1) :
// else
xn );
}
template<typename T>
constexpr
T
sqrt_check(const T x, const T m_val)
sqrt_simplify(const T x, const T m_val)
noexcept
{
return( x > T(1e+08) ? \
sqrt_simplify(x / T(1e+08), T(1e+04) * m_val) :
x > T(1e+06) ? \
sqrt_simplify(x / T(1e+06), T(1e+03) * m_val) :
x > T(1e+04) ? \
sqrt_simplify(x / T(1e+04), T(1e+02) * m_val) :
x > T(100) ? \
sqrt_simplify(x / T(100), T(10) * m_val) :
x > T(4) ? \
sqrt_simplify(x / T(4), T(2) * m_val) :
m_val * sqrt_recur(x, x / T(2), 0) );
}
template<typename T>
constexpr
T
sqrt_check(const T x)
noexcept
{
return( is_nan(x) ? \
@@ -63,9 +84,7 @@ noexcept
GCLIM<T>::min() > abs(T(1) - x) ? \
x :
// else
x > T(4) ? \
sqrt_check(x/T(4), T(2)*m_val) :
m_val * sqrt_recur(x, x/T(2), 0) );
sqrt_simplify(x, T(1)) );
}
}
@@ -84,7 +103,7 @@ return_t<T>
sqrt(const T x)
noexcept
{
return internal::sqrt_check( static_cast<return_t<T>>(x), return_t<T>(1) );
return internal::sqrt_check( static_cast<return_t<T>>(x) );
}
#endif

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##

View File

@@ -1,6 +1,6 @@
/*################################################################################
##
## Copyright (C) 2016-2022 Keith O'Hara
## Copyright (C) 2016-2023 Keith O'Hara
##
## This file is part of the GCE-Math C++ library.
##