mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-01-23 20:46:37 +00:00
workaround for no c++11 numeric_limits
This commit is contained in:
parent
ce16e24637
commit
7a1974742a
110 changed files with 727 additions and 436 deletions
|
@ -5,8 +5,8 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <limits>
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/container/functions.hpp>
|
#include <sprout/container/functions.hpp>
|
||||||
#include <sprout/iterator/operation.hpp>
|
#include <sprout/iterator/operation.hpp>
|
||||||
#include <sprout/iterator/bytes_iterator.hpp>
|
#include <sprout/iterator/bytes_iterator.hpp>
|
||||||
|
@ -84,7 +84,7 @@ namespace sprout {
|
||||||
}
|
}
|
||||||
|
|
||||||
SPROUT_CONSTEXPR value_type checksum() const {
|
SPROUT_CONSTEXPR value_type checksum() const {
|
||||||
return static_cast<value_type>(sum_ & std::numeric_limits<value_type>::max());
|
return static_cast<value_type>(sum_ & sprout::numeric_limits<value_type>::max());
|
||||||
}
|
}
|
||||||
SPROUT_CONSTEXPR value_type operator()() const {
|
SPROUT_CONSTEXPR value_type operator()() const {
|
||||||
return checksum();
|
return checksum();
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#define SPROUT_COMPOST_FORMATS_AS_PCM_WAVE_HPP
|
#define SPROUT_COMPOST_FORMATS_AS_PCM_WAVE_HPP
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/algorithm/clamp.hpp>
|
#include <sprout/algorithm/clamp.hpp>
|
||||||
#include <sprout/utility/forward.hpp>
|
#include <sprout/utility/forward.hpp>
|
||||||
#include <sprout/type_traits/is_int.hpp>
|
#include <sprout/type_traits/is_int.hpp>
|
||||||
|
@ -26,7 +26,7 @@ namespace sprout {
|
||||||
public:
|
public:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
SPROUT_CONSTEXPR result_type operator()(T const& x) const {
|
SPROUT_CONSTEXPR result_type operator()(T const& x) const {
|
||||||
return static_cast<result_type>(sprout::clamp(x, -1, 1) * std::numeric_limits<result_type>::max());
|
return static_cast<result_type>(sprout::clamp(x, -1, 1) * sprout::numeric_limits<result_type>::max());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template<typename IntType>
|
template<typename IntType>
|
||||||
|
@ -39,7 +39,7 @@ namespace sprout {
|
||||||
public:
|
public:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
SPROUT_CONSTEXPR result_type operator()(T const& x) const {
|
SPROUT_CONSTEXPR result_type operator()(T const& x) const {
|
||||||
return static_cast<result_type>(sprout::clamp((x + 1) / 2, 0, 1) * std::numeric_limits<result_type>::max());
|
return static_cast<result_type>(sprout::clamp((x + 1) / 2, 0, 1) * sprout::numeric_limits<result_type>::max());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
|
@ -11,8 +11,9 @@
|
||||||
#define SPROUT_NO_CXX11_ATOMIC_SMART_PTR
|
#define SPROUT_NO_CXX11_ATOMIC_SMART_PTR
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#if defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION < 1101)
|
#if defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION <= 1001)
|
||||||
# define SPROUT_NO_CXX11_CHAR_TRAITS
|
# define SPROUT_NO_CXX11_CHAR_TRAITS
|
||||||
|
# define SPROUT_NO_CXX11_NUMERIC_LIMITS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_CONFIG_STDLIB_LIBCPP_HPP
|
#endif // #ifndef SPROUT_CONFIG_STDLIB_LIBCPP_HPP
|
||||||
|
|
|
@ -26,7 +26,18 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
|
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||||
|
# if defined(__clang__)
|
||||||
|
# if !__has_feature(cxx_constexpr) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||||
|
# define SPROUT_NO_CXX11_CHAR_TRAITS
|
||||||
# define SPROUT_NO_CXX11_NUMERIC_LIMITS
|
# define SPROUT_NO_CXX11_NUMERIC_LIMITS
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# define SPROUT_NO_CXX11_CHAR_TRAITS
|
||||||
|
# define SPROUT_NO_CXX11_NUMERIC_LIMITS
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) || !defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||||
# define SPROUT_NO_CXX11_HDR_FUTURE
|
# define SPROUT_NO_CXX11_HDR_FUTURE
|
||||||
# define SPROUT_NO_CXX11_HDR_RANDOM
|
# define SPROUT_NO_CXX11_HDR_RANDOM
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#define SPROUT_CSTDLIB_DECIMAL_TO_INT_HPP
|
#define SPROUT_CSTDLIB_DECIMAL_TO_INT_HPP
|
||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/iterator/operation.hpp>
|
#include <sprout/iterator/operation.hpp>
|
||||||
#include <sprout/ctype/ascii.hpp>
|
#include <sprout/ctype/ascii.hpp>
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ namespace sprout {
|
||||||
ascii_to_int_impl(CStrIterator str, IntType val, bool negative) {
|
ascii_to_int_impl(CStrIterator str, IntType val, bool negative) {
|
||||||
return !sprout::ascii::isdigit(*str)
|
return !sprout::ascii::isdigit(*str)
|
||||||
? negative ? -val : val
|
? negative ? -val : val
|
||||||
: val > (std::numeric_limits<IntType>::max() - (*str - static_cast<typename std::iterator_traits<CStrIterator>::value_type>('0')) - (negative ? 1 : 0)) / 10
|
: val > (sprout::numeric_limits<IntType>::max() - (*str - static_cast<typename std::iterator_traits<CStrIterator>::value_type>('0')) - (negative ? 1 : 0)) / 10
|
||||||
? (negative ? std::numeric_limits<IntType>::min() : std::numeric_limits<IntType>::max())
|
? (negative ? sprout::numeric_limits<IntType>::min() : sprout::numeric_limits<IntType>::max())
|
||||||
: sprout::detail::ascii_to_int_impl<IntType>(
|
: sprout::detail::ascii_to_int_impl<IntType>(
|
||||||
sprout::next(str),
|
sprout::next(str),
|
||||||
val * 10 + (*str - static_cast<typename std::iterator_traits<CStrIterator>::value_type>('0')),
|
val * 10 + (*str - static_cast<typename std::iterator_traits<CStrIterator>::value_type>('0')),
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/iterator/operation.hpp>
|
#include <sprout/iterator/operation.hpp>
|
||||||
#include <sprout/ctype/ascii.hpp>
|
#include <sprout/ctype/ascii.hpp>
|
||||||
|
|
||||||
|
@ -48,8 +48,8 @@ namespace sprout {
|
||||||
long exponent = 0
|
long exponent = 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return exponent >= std::numeric_limits<FloatType>::min_exponent
|
return exponent >= sprout::numeric_limits<FloatType>::min_exponent
|
||||||
&& exponent <= std::numeric_limits<FloatType>::max_exponent
|
&& exponent <= sprout::numeric_limits<FloatType>::max_exponent
|
||||||
? sprout::detail::str_to_float_impl_scale<FloatType>(
|
? sprout::detail::str_to_float_impl_scale<FloatType>(
|
||||||
str,
|
str,
|
||||||
negative,
|
negative,
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
#if !defined(_MSC_VER)
|
#if !defined(_MSC_VER)
|
||||||
# include <cinttypes>
|
# include <cinttypes>
|
||||||
#endif
|
#endif
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/iterator/operation.hpp>
|
#include <sprout/iterator/operation.hpp>
|
||||||
#include <sprout/ctype/ascii.hpp>
|
#include <sprout/ctype/ascii.hpp>
|
||||||
#include <sprout/detail/char_conversion.hpp>
|
#include <sprout/detail/char_conversion.hpp>
|
||||||
|
@ -21,8 +21,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR IntType
|
inline SPROUT_CONSTEXPR IntType
|
||||||
str_to_int_impl_1(CStrIterator str, int base, IntType val, IntType x, bool negative) {
|
str_to_int_impl_1(CStrIterator str, int base, IntType val, IntType x, bool negative) {
|
||||||
return x == static_cast<IntType>(-1) ? (negative ? -1 * val : val)
|
return x == static_cast<IntType>(-1) ? (negative ? -1 * val : val)
|
||||||
: val > (std::numeric_limits<IntType>::max() - x - (negative ? 1 : 0)) / base
|
: val > (sprout::numeric_limits<IntType>::max() - x - (negative ? 1 : 0)) / base
|
||||||
? (negative ? std::numeric_limits<IntType>::min() : std::numeric_limits<IntType>::max())
|
? (negative ? sprout::numeric_limits<IntType>::min() : sprout::numeric_limits<IntType>::max())
|
||||||
: sprout::detail::str_to_int_impl_1<IntType>(
|
: sprout::detail::str_to_int_impl_1<IntType>(
|
||||||
sprout::next(str),
|
sprout::next(str),
|
||||||
base,
|
base,
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#define SPROUT_DARKROOM_COLORS_RGB_HPP
|
#define SPROUT_DARKROOM_COLORS_RGB_HPP
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/tuple/tuple.hpp>
|
#include <sprout/tuple/tuple.hpp>
|
||||||
#include <sprout/tuple/functions.hpp>
|
#include <sprout/tuple/functions.hpp>
|
||||||
#include <sprout/utility/forward.hpp>
|
#include <sprout/utility/forward.hpp>
|
||||||
|
@ -121,17 +121,17 @@ namespace sprout {
|
||||||
rgb_f_to_rgb(RGB_F const& col) {
|
rgb_f_to_rgb(RGB_F const& col) {
|
||||||
typedef typename sprout::darkroom::access::unit<RGB>::type unit_type;
|
typedef typename sprout::darkroom::access::unit<RGB>::type unit_type;
|
||||||
return sprout::tuples::make<RGB>(
|
return sprout::tuples::make<RGB>(
|
||||||
sprout::darkroom::colors::r(col) < 0 ? std::numeric_limits<unit_type>::min()
|
sprout::darkroom::colors::r(col) < 0 ? sprout::numeric_limits<unit_type>::min()
|
||||||
: sprout::darkroom::colors::r(col) > 1 ? std::numeric_limits<unit_type>::max()
|
: sprout::darkroom::colors::r(col) > 1 ? sprout::numeric_limits<unit_type>::max()
|
||||||
: sprout::darkroom::colors::r(col) * std::numeric_limits<unit_type>::max()
|
: sprout::darkroom::colors::r(col) * sprout::numeric_limits<unit_type>::max()
|
||||||
,
|
,
|
||||||
sprout::darkroom::colors::g(col) < 0 ? std::numeric_limits<unit_type>::min()
|
sprout::darkroom::colors::g(col) < 0 ? sprout::numeric_limits<unit_type>::min()
|
||||||
: sprout::darkroom::colors::g(col) > 1 ? std::numeric_limits<unit_type>::max()
|
: sprout::darkroom::colors::g(col) > 1 ? sprout::numeric_limits<unit_type>::max()
|
||||||
: sprout::darkroom::colors::g(col) * std::numeric_limits<unit_type>::max()
|
: sprout::darkroom::colors::g(col) * sprout::numeric_limits<unit_type>::max()
|
||||||
,
|
,
|
||||||
sprout::darkroom::colors::b(col) < 0 ? std::numeric_limits<unit_type>::min()
|
sprout::darkroom::colors::b(col) < 0 ? sprout::numeric_limits<unit_type>::min()
|
||||||
: sprout::darkroom::colors::b(col) > 1 ? std::numeric_limits<unit_type>::max()
|
: sprout::darkroom::colors::b(col) > 1 ? sprout::numeric_limits<unit_type>::max()
|
||||||
: sprout::darkroom::colors::b(col) * std::numeric_limits<unit_type>::max()
|
: sprout::darkroom::colors::b(col) * sprout::numeric_limits<unit_type>::max()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} // namespace colors
|
} // namespace colors
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef SPROUT_DARKROOM_LIGHTS_AMBIENT_LIGHT_HPP
|
#ifndef SPROUT_DARKROOM_LIGHTS_AMBIENT_LIGHT_HPP
|
||||||
#define SPROUT_DARKROOM_LIGHTS_AMBIENT_LIGHT_HPP
|
#define SPROUT_DARKROOM_LIGHTS_AMBIENT_LIGHT_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/tuple/tuple.hpp>
|
#include <sprout/tuple/tuple.hpp>
|
||||||
#include <sprout/tuple/functions.hpp>
|
#include <sprout/tuple/functions.hpp>
|
||||||
#include <sprout/darkroom/colors/rgb.hpp>
|
#include <sprout/darkroom/colors/rgb.hpp>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef SPROUT_DARKROOM_LIGHTS_LIGHT_LIST_HPP
|
#ifndef SPROUT_DARKROOM_LIGHTS_LIGHT_LIST_HPP
|
||||||
#define SPROUT_DARKROOM_LIGHTS_LIGHT_LIST_HPP
|
#define SPROUT_DARKROOM_LIGHTS_LIGHT_LIST_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/index_tuple/metafunction.hpp>
|
#include <sprout/index_tuple/metafunction.hpp>
|
||||||
#include <sprout/tuple/tuple.hpp>
|
#include <sprout/tuple/tuple.hpp>
|
||||||
#include <sprout/darkroom/access/access.hpp>
|
#include <sprout/darkroom/access/access.hpp>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef SPROUT_DARKROOM_LIGHTS_PARALLEL_LIGHT_HPP
|
#ifndef SPROUT_DARKROOM_LIGHTS_PARALLEL_LIGHT_HPP
|
||||||
#define SPROUT_DARKROOM_LIGHTS_PARALLEL_LIGHT_HPP
|
#define SPROUT_DARKROOM_LIGHTS_PARALLEL_LIGHT_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/darkroom/access/access.hpp>
|
#include <sprout/darkroom/access/access.hpp>
|
||||||
#include <sprout/darkroom/colors/rgb.hpp>
|
#include <sprout/darkroom/colors/rgb.hpp>
|
||||||
#include <sprout/darkroom/coords/vector.hpp>
|
#include <sprout/darkroom/coords/vector.hpp>
|
||||||
|
@ -49,9 +49,9 @@ namespace sprout {
|
||||||
inter,
|
inter,
|
||||||
!sprout::darkroom::intersects::does_intersect(light_ray_inter)
|
!sprout::darkroom::intersects::does_intersect(light_ray_inter)
|
||||||
|| sprout::darkroom::intersects::distance(light_ray_inter)
|
|| sprout::darkroom::intersects::distance(light_ray_inter)
|
||||||
< std::numeric_limits<unit_type>::epsilon()
|
< sprout::numeric_limits<unit_type>::epsilon()
|
||||||
? NS_SSCRISK_CEL_OR_SPROUT::max(
|
? NS_SSCRISK_CEL_OR_SPROUT::max(
|
||||||
std::numeric_limits<unit_type>::epsilon(),
|
sprout::numeric_limits<unit_type>::epsilon(),
|
||||||
sprout::darkroom::coords::dot(
|
sprout::darkroom::coords::dot(
|
||||||
dir_,
|
dir_,
|
||||||
sprout::darkroom::intersects::normal(inter)
|
sprout::darkroom::intersects::normal(inter)
|
||||||
|
@ -76,7 +76,7 @@ namespace sprout {
|
||||||
sprout::darkroom::coords::add(
|
sprout::darkroom::coords::add(
|
||||||
sprout::darkroom::coords::scale(
|
sprout::darkroom::coords::scale(
|
||||||
dir_,
|
dir_,
|
||||||
std::numeric_limits<unit_type>::epsilon() * 256
|
sprout::numeric_limits<unit_type>::epsilon() * 256
|
||||||
),
|
),
|
||||||
sprout::darkroom::intersects::point_of_intersection(inter)
|
sprout::darkroom::intersects::point_of_intersection(inter)
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef SPROUT_DARKROOM_LIGHTS_POINT_LIGHT_HPP
|
#ifndef SPROUT_DARKROOM_LIGHTS_POINT_LIGHT_HPP
|
||||||
#define SPROUT_DARKROOM_LIGHTS_POINT_LIGHT_HPP
|
#define SPROUT_DARKROOM_LIGHTS_POINT_LIGHT_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/darkroom/access/access.hpp>
|
#include <sprout/darkroom/access/access.hpp>
|
||||||
#include <sprout/darkroom/colors/rgb.hpp>
|
#include <sprout/darkroom/colors/rgb.hpp>
|
||||||
#include <sprout/darkroom/coords/vector.hpp>
|
#include <sprout/darkroom/coords/vector.hpp>
|
||||||
|
@ -55,9 +55,9 @@ namespace sprout {
|
||||||
|| sprout::darkroom::intersects::distance(light_ray_inter)
|
|| sprout::darkroom::intersects::distance(light_ray_inter)
|
||||||
> sprout::darkroom::coords::length(diff)
|
> sprout::darkroom::coords::length(diff)
|
||||||
|| sprout::darkroom::intersects::distance(light_ray_inter)
|
|| sprout::darkroom::intersects::distance(light_ray_inter)
|
||||||
< std::numeric_limits<unit_type>::epsilon()
|
< sprout::numeric_limits<unit_type>::epsilon()
|
||||||
? NS_SSCRISK_CEL_OR_SPROUT::max(
|
? NS_SSCRISK_CEL_OR_SPROUT::max(
|
||||||
std::numeric_limits<unit_type>::epsilon(),
|
sprout::numeric_limits<unit_type>::epsilon(),
|
||||||
sprout::darkroom::coords::dot(
|
sprout::darkroom::coords::dot(
|
||||||
direction,
|
direction,
|
||||||
sprout::darkroom::intersects::normal(inter)
|
sprout::darkroom::intersects::normal(inter)
|
||||||
|
@ -80,7 +80,7 @@ namespace sprout {
|
||||||
sprout::darkroom::coords::add(
|
sprout::darkroom::coords::add(
|
||||||
sprout::darkroom::coords::scale(
|
sprout::darkroom::coords::scale(
|
||||||
direction,
|
direction,
|
||||||
std::numeric_limits<unit_type>::epsilon() * 256
|
sprout::numeric_limits<unit_type>::epsilon() * 256
|
||||||
),
|
),
|
||||||
sprout::darkroom::intersects::point_of_intersection(inter)
|
sprout::darkroom::intersects::point_of_intersection(inter)
|
||||||
),
|
),
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#define SPROUT_DARKROOM_RENDERERS_WHITTED_STYLE_HPP
|
#define SPROUT_DARKROOM_RENDERERS_WHITTED_STYLE_HPP
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/tuple/functions.hpp>
|
#include <sprout/tuple/functions.hpp>
|
||||||
#include <sprout/darkroom/access/access.hpp>
|
#include <sprout/darkroom/access/access.hpp>
|
||||||
#include <sprout/darkroom/colors/rgb.hpp>
|
#include <sprout/darkroom/colors/rgb.hpp>
|
||||||
|
@ -45,12 +45,12 @@ namespace sprout {
|
||||||
sprout::darkroom::intersects::point_of_intersection(inter),
|
sprout::darkroom::intersects::point_of_intersection(inter),
|
||||||
sprout::darkroom::coords::scale(
|
sprout::darkroom::coords::scale(
|
||||||
reflect_dir,
|
reflect_dir,
|
||||||
std::numeric_limits<typename sprout::darkroom::access::unit<Direction>::type>::epsilon() * 256
|
sprout::numeric_limits<typename sprout::darkroom::access::unit<Direction>::type>::epsilon() * 256
|
||||||
)
|
)
|
||||||
// ???
|
// ???
|
||||||
// sprout::darkroom::coords::scale(
|
// sprout::darkroom::coords::scale(
|
||||||
// sprout::darkroom::intersects::normal(inter),
|
// sprout::darkroom::intersects::normal(inter),
|
||||||
// std::numeric_limits<typename sprout::darkroom::access::unit<Direction>::type>::epsilon() * 256
|
// sprout::numeric_limits<typename sprout::darkroom::access::unit<Direction>::type>::epsilon() * 256
|
||||||
// )
|
// )
|
||||||
),
|
),
|
||||||
reflect_dir
|
reflect_dir
|
||||||
|
@ -77,7 +77,7 @@ namespace sprout {
|
||||||
return depth_max > 0
|
return depth_max > 0
|
||||||
&& sprout::darkroom::intersects::does_intersect(inter)
|
&& sprout::darkroom::intersects::does_intersect(inter)
|
||||||
&& sprout::darkroom::materials::reflection(sprout::darkroom::intersects::material(inter))
|
&& sprout::darkroom::materials::reflection(sprout::darkroom::intersects::material(inter))
|
||||||
> std::numeric_limits<reflection_type>::epsilon()
|
> sprout::numeric_limits<reflection_type>::epsilon()
|
||||||
? color_1<Color>(
|
? color_1<Color>(
|
||||||
camera, objs, lights,
|
camera, objs, lights,
|
||||||
ray, inter, tracer,
|
ray, inter, tracer,
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#define SPROUT_DETAIL_INTEGER_HPP
|
#define SPROUT_DETAIL_INTEGER_HPP
|
||||||
|
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <limits>
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
@ -115,11 +115,11 @@ namespace sprout {
|
||||||
{
|
{
|
||||||
typedef typename sprout::detail::int_least_helper<
|
typedef typename sprout::detail::int_least_helper<
|
||||||
0
|
0
|
||||||
+ (Bits - 1 <= std::numeric_limits<long long>::digits)
|
+ (Bits - 1 <= sprout::numeric_limits<long long>::digits)
|
||||||
+ (Bits - 1 <= std::numeric_limits<long>::digits)
|
+ (Bits - 1 <= sprout::numeric_limits<long>::digits)
|
||||||
+ (Bits - 1 <= std::numeric_limits<int>::digits)
|
+ (Bits - 1 <= sprout::numeric_limits<int>::digits)
|
||||||
+ (Bits - 1 <= std::numeric_limits<short>::digits)
|
+ (Bits - 1 <= sprout::numeric_limits<short>::digits)
|
||||||
+ (Bits - 1 <= std::numeric_limits<signed char>::digits)
|
+ (Bits - 1 <= sprout::numeric_limits<signed char>::digits)
|
||||||
>::least least;
|
>::least least;
|
||||||
typedef typename sprout::detail::int_fast_t<least>::type fast;
|
typedef typename sprout::detail::int_fast_t<least>::type fast;
|
||||||
};
|
};
|
||||||
|
@ -129,11 +129,11 @@ namespace sprout {
|
||||||
{
|
{
|
||||||
typedef typename sprout::detail::int_least_helper<
|
typedef typename sprout::detail::int_least_helper<
|
||||||
5
|
5
|
||||||
+ (Bits <= std::numeric_limits<unsigned long long>::digits)
|
+ (Bits <= sprout::numeric_limits<unsigned long long>::digits)
|
||||||
+ (Bits <= std::numeric_limits<unsigned long>::digits)
|
+ (Bits <= sprout::numeric_limits<unsigned long>::digits)
|
||||||
+ (Bits <= std::numeric_limits<unsigned int>::digits)
|
+ (Bits <= sprout::numeric_limits<unsigned int>::digits)
|
||||||
+ (Bits <= std::numeric_limits<unsigned short>::digits)
|
+ (Bits <= sprout::numeric_limits<unsigned short>::digits)
|
||||||
+ (Bits <= std::numeric_limits<unsigned char>::digits)
|
+ (Bits <= sprout::numeric_limits<unsigned char>::digits)
|
||||||
>::least least;
|
>::least least;
|
||||||
typedef typename sprout::detail::int_fast_t<least>::type fast;
|
typedef typename sprout::detail::int_fast_t<least>::type fast;
|
||||||
};
|
};
|
||||||
|
@ -142,11 +142,11 @@ namespace sprout {
|
||||||
struct int_max_value_t {
|
struct int_max_value_t {
|
||||||
typedef typename sprout::detail::int_least_helper<
|
typedef typename sprout::detail::int_least_helper<
|
||||||
0
|
0
|
||||||
+ (MaxValue <= std::numeric_limits<long long>::max())
|
+ (MaxValue <= sprout::numeric_limits<long long>::max())
|
||||||
+ (MaxValue <= std::numeric_limits<long>::max())
|
+ (MaxValue <= sprout::numeric_limits<long>::max())
|
||||||
+ (MaxValue <= std::numeric_limits<int>::max())
|
+ (MaxValue <= sprout::numeric_limits<int>::max())
|
||||||
+ (MaxValue <= std::numeric_limits<short>::max())
|
+ (MaxValue <= sprout::numeric_limits<short>::max())
|
||||||
+ (MaxValue <= std::numeric_limits<signed char>::max())
|
+ (MaxValue <= sprout::numeric_limits<signed char>::max())
|
||||||
>::least least;
|
>::least least;
|
||||||
typedef typename sprout::detail::int_fast_t<least>::type fast;
|
typedef typename sprout::detail::int_fast_t<least>::type fast;
|
||||||
};
|
};
|
||||||
|
@ -154,11 +154,11 @@ namespace sprout {
|
||||||
struct int_min_value_t {
|
struct int_min_value_t {
|
||||||
typedef typename sprout::detail::int_least_helper<
|
typedef typename sprout::detail::int_least_helper<
|
||||||
0
|
0
|
||||||
+ (MinValue >= std::numeric_limits<long long>::min())
|
+ (MinValue >= sprout::numeric_limits<long long>::min())
|
||||||
+ (MinValue >= std::numeric_limits<long>::min())
|
+ (MinValue >= sprout::numeric_limits<long>::min())
|
||||||
+ (MinValue >= std::numeric_limits<int>::min())
|
+ (MinValue >= sprout::numeric_limits<int>::min())
|
||||||
+ (MinValue >= std::numeric_limits<short>::min())
|
+ (MinValue >= sprout::numeric_limits<short>::min())
|
||||||
+ (MinValue >= std::numeric_limits<signed char>::min())
|
+ (MinValue >= sprout::numeric_limits<signed char>::min())
|
||||||
>::least least;
|
>::least least;
|
||||||
typedef typename sprout::detail::int_fast_t<least>::type fast;
|
typedef typename sprout::detail::int_fast_t<least>::type fast;
|
||||||
};
|
};
|
||||||
|
@ -167,11 +167,11 @@ namespace sprout {
|
||||||
struct uint_value_t {
|
struct uint_value_t {
|
||||||
typedef typename sprout::detail::int_least_helper<
|
typedef typename sprout::detail::int_least_helper<
|
||||||
5
|
5
|
||||||
+ (MaxValue <= std::numeric_limits<long long>::max())
|
+ (MaxValue <= sprout::numeric_limits<long long>::max())
|
||||||
+ (MaxValue <= std::numeric_limits<long>::max())
|
+ (MaxValue <= sprout::numeric_limits<long>::max())
|
||||||
+ (MaxValue <= std::numeric_limits<int>::max())
|
+ (MaxValue <= sprout::numeric_limits<int>::max())
|
||||||
+ (MaxValue <= std::numeric_limits<short>::max())
|
+ (MaxValue <= sprout::numeric_limits<short>::max())
|
||||||
+ (MaxValue <= std::numeric_limits<signed char>::max())
|
+ (MaxValue <= sprout::numeric_limits<signed char>::max())
|
||||||
>::least least;
|
>::least least;
|
||||||
typedef typename sprout::detail::int_fast_t<least>::type fast;
|
typedef typename sprout::detail::int_fast_t<least>::type fast;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <limits>
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/detail/integer.hpp>
|
#include <sprout/detail/integer.hpp>
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
|
@ -33,9 +33,9 @@ namespace sprout {
|
||||||
|
|
||||||
#define SPROUT_LOW_BITS_MASK_SPECIALIZE(Type) \
|
#define SPROUT_LOW_BITS_MASK_SPECIALIZE(Type) \
|
||||||
template<> \
|
template<> \
|
||||||
struct low_bits_mask_t<std::numeric_limits<Type>::digits> { \
|
struct low_bits_mask_t<sprout::numeric_limits<Type>::digits> { \
|
||||||
public: \
|
public: \
|
||||||
typedef std::numeric_limits<Type> limits_type; \
|
typedef sprout::numeric_limits<Type> limits_type; \
|
||||||
typedef typename sprout::detail::uint_t<limits_type::digits>::least least; \
|
typedef typename sprout::detail::uint_t<limits_type::digits>::least least; \
|
||||||
typedef typename sprout::detail::uint_t<limits_type::digits>::fast fast; \
|
typedef typename sprout::detail::uint_t<limits_type::digits>::fast fast; \
|
||||||
public: \
|
public: \
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/utility/move.hpp>
|
#include <sprout/utility/move.hpp>
|
||||||
#include <sprout/utility/swap.hpp>
|
#include <sprout/utility/swap.hpp>
|
||||||
#include <sprout/utility/value_holder/value_holder.hpp>
|
#include <sprout/utility/value_holder/value_holder.hpp>
|
||||||
|
@ -361,7 +361,7 @@ namespace sprout {
|
||||||
return !!fst.next;
|
return !!fst.next;
|
||||||
}
|
}
|
||||||
SPROUT_CONSTEXPR size_type max_size() const SPROUT_NOEXCEPT {
|
SPROUT_CONSTEXPR size_type max_size() const SPROUT_NOEXCEPT {
|
||||||
return std::numeric_limits<size_type>::max();
|
return sprout::numeric_limits<size_type>::max();
|
||||||
}
|
}
|
||||||
// element access:
|
// element access:
|
||||||
SPROUT_CXX14_CONSTEXPR reference front() {
|
SPROUT_CXX14_CONSTEXPR reference front() {
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#define SPROUT_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_HPP
|
#define SPROUT_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_HPP
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <limits>
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/functional/hash/hash_fwd.hpp>
|
#include <sprout/functional/hash/hash_fwd.hpp>
|
||||||
#include <sprout/math/fpclassify.hpp>
|
#include <sprout/math/fpclassify.hpp>
|
||||||
#include <sprout/math/ldexp.hpp>
|
#include <sprout/math/ldexp.hpp>
|
||||||
|
@ -21,7 +21,7 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR std::size_t
|
inline SPROUT_CONSTEXPR std::size_t
|
||||||
float_hash_value_impl_4(T v, int exp, std::size_t seed, std::size_t length, std::size_t i = 0) {
|
float_hash_value_impl_4(T v, int exp, std::size_t seed, std::size_t length, std::size_t i = 0) {
|
||||||
return i != length ? sprout::detail::float_hash_value_impl_4(
|
return i != length ? sprout::detail::float_hash_value_impl_4(
|
||||||
sprout::ldexp(v - static_cast<T>(static_cast<std::size_t>(v)), std::numeric_limits<std::size_t>::digits),
|
sprout::ldexp(v - static_cast<T>(static_cast<std::size_t>(v)), sprout::numeric_limits<std::size_t>::digits),
|
||||||
exp, sprout::detail::hash_float_combine(seed, static_cast<std::size_t>(v)),
|
exp, sprout::detail::hash_float_combine(seed, static_cast<std::size_t>(v)),
|
||||||
length, i + 1
|
length, i + 1
|
||||||
)
|
)
|
||||||
|
@ -32,22 +32,22 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR std::size_t
|
inline SPROUT_CONSTEXPR std::size_t
|
||||||
float_hash_value_impl_3(T v, int exp) {
|
float_hash_value_impl_3(T v, int exp) {
|
||||||
return sprout::detail::float_hash_value_impl_4(
|
return sprout::detail::float_hash_value_impl_4(
|
||||||
sprout::ldexp(v - static_cast<T>(static_cast<std::size_t>(v)), std::numeric_limits<std::size_t>::digits),
|
sprout::ldexp(v - static_cast<T>(static_cast<std::size_t>(v)), sprout::numeric_limits<std::size_t>::digits),
|
||||||
exp, static_cast<std::size_t>(v),
|
exp, static_cast<std::size_t>(v),
|
||||||
(std::numeric_limits<T>::digits * sprout::detail::static_log2<std::numeric_limits<T>::radix>::value + std::numeric_limits<std::size_t>::digits - 1)
|
(sprout::numeric_limits<T>::digits * sprout::detail::static_log2<sprout::numeric_limits<T>::radix>::value + sprout::numeric_limits<std::size_t>::digits - 1)
|
||||||
/ std::numeric_limits<std::size_t>::digits
|
/ sprout::numeric_limits<std::size_t>::digits
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline SPROUT_CONSTEXPR std::size_t
|
inline SPROUT_CONSTEXPR std::size_t
|
||||||
float_hash_value_impl_2(T v, int exp) {
|
float_hash_value_impl_2(T v, int exp) {
|
||||||
return sprout::detail::float_hash_value_impl_3(sprout::ldexp(v, std::numeric_limits<std::size_t>::digits), exp);
|
return sprout::detail::float_hash_value_impl_3(sprout::ldexp(v, sprout::numeric_limits<std::size_t>::digits), exp);
|
||||||
}
|
}
|
||||||
template<typename T, typename P>
|
template<typename T, typename P>
|
||||||
inline SPROUT_CONSTEXPR std::size_t
|
inline SPROUT_CONSTEXPR std::size_t
|
||||||
float_hash_value_impl_1(P const& p) {
|
float_hash_value_impl_1(P const& p) {
|
||||||
return ((p.first) < 0) ? sprout::detail::float_hash_value_impl_2(
|
return ((p.first) < 0) ? sprout::detail::float_hash_value_impl_2(
|
||||||
-p.first, p.second + (std::numeric_limits<T>::max_exponent - std::numeric_limits<T>::min_exponent)
|
-p.first, p.second + (sprout::numeric_limits<T>::max_exponent - sprout::numeric_limits<T>::min_exponent)
|
||||||
)
|
)
|
||||||
: sprout::detail::float_hash_value_impl_2(p.first, p.second)
|
: sprout::detail::float_hash_value_impl_2(p.first, p.second)
|
||||||
;
|
;
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
#define SPROUT_FUNCTIONAL_HASH_HASH_VALUE_TRAITS_HPP
|
#define SPROUT_FUNCTIONAL_HASH_HASH_VALUE_TRAITS_HPP
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <limits>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/functional/hash/hash_fwd.hpp>
|
#include <sprout/functional/hash/hash_fwd.hpp>
|
||||||
#include <sprout/functional/hash/detail/hash_float.hpp>
|
#include <sprout/functional/hash/detail/hash_float.hpp>
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ namespace sprout {
|
||||||
length,
|
length,
|
||||||
seed ^ static_cast<std::size_t>((positive >> i) + (seed << 6) + (seed >> 2)),
|
seed ^ static_cast<std::size_t>((positive >> i) + (seed << 6) + (seed >> 2)),
|
||||||
positive,
|
positive,
|
||||||
i - std::numeric_limits<std::size_t>::digits
|
i - sprout::numeric_limits<std::size_t>::digits
|
||||||
)
|
)
|
||||||
: seed ^ static_cast<std::size_t>(val + (seed << 6) + (seed >> 2))
|
: seed ^ static_cast<std::size_t>(val + (seed << 6) + (seed >> 2))
|
||||||
;
|
;
|
||||||
|
@ -55,14 +55,14 @@ namespace sprout {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline SPROUT_CONSTEXPR std::size_t
|
inline SPROUT_CONSTEXPR std::size_t
|
||||||
hash_value_signed_1(T val, int length, std::size_t seed, T positive) {
|
hash_value_signed_1(T val, int length, std::size_t seed, T positive) {
|
||||||
return hash_value_signed_2(val, length, seed, positive, length * std::numeric_limits<std::size_t>::digits);
|
return hash_value_signed_2(val, length, seed, positive, length * sprout::numeric_limits<std::size_t>::digits);
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline SPROUT_CONSTEXPR std::size_t
|
inline SPROUT_CONSTEXPR std::size_t
|
||||||
hash_value_signed(T val) {
|
hash_value_signed(T val) {
|
||||||
return sprout::hash_detail::hash_value_signed_1(
|
return sprout::hash_detail::hash_value_signed_1(
|
||||||
val,
|
val,
|
||||||
(std::numeric_limits<T>::digits - 1) / std::numeric_limits<std::size_t>::digits,
|
(sprout::numeric_limits<T>::digits - 1) / sprout::numeric_limits<std::size_t>::digits,
|
||||||
0,
|
0,
|
||||||
val < 0 ? -1 - val : val
|
val < 0 ? -1 - val : val
|
||||||
);
|
);
|
||||||
|
@ -76,7 +76,7 @@ namespace sprout {
|
||||||
val,
|
val,
|
||||||
length,
|
length,
|
||||||
seed ^ static_cast<std::size_t>((val >> i) + (seed << 6) + (seed >> 2)),
|
seed ^ static_cast<std::size_t>((val >> i) + (seed << 6) + (seed >> 2)),
|
||||||
i - std::numeric_limits<std::size_t>::digits
|
i - sprout::numeric_limits<std::size_t>::digits
|
||||||
)
|
)
|
||||||
: seed ^ static_cast<std::size_t>(val + (seed << 6) + (seed >> 2))
|
: seed ^ static_cast<std::size_t>(val + (seed << 6) + (seed >> 2))
|
||||||
;
|
;
|
||||||
|
@ -84,14 +84,14 @@ namespace sprout {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline SPROUT_CONSTEXPR std::size_t
|
inline SPROUT_CONSTEXPR std::size_t
|
||||||
hash_value_unsigned_1(T val, int length, std::size_t seed) {
|
hash_value_unsigned_1(T val, int length, std::size_t seed) {
|
||||||
return hash_value_unsigned_2(val, length, seed, length * std::numeric_limits<std::size_t>::digits);
|
return hash_value_unsigned_2(val, length, seed, length * sprout::numeric_limits<std::size_t>::digits);
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline SPROUT_CONSTEXPR std::size_t
|
inline SPROUT_CONSTEXPR std::size_t
|
||||||
hash_value_unsigned(T val) {
|
hash_value_unsigned(T val) {
|
||||||
return sprout::hash_detail::hash_value_unsigned_1(
|
return sprout::hash_detail::hash_value_unsigned_1(
|
||||||
val,
|
val,
|
||||||
(std::numeric_limits<T>::digits - 1) / std::numeric_limits<std::size_t>::digits,
|
(sprout::numeric_limits<T>::digits - 1) / sprout::numeric_limits<std::size_t>::digits,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#ifndef SPROUT_ITERATOR_COUNTING_ITERATOR_HPP
|
#ifndef SPROUT_ITERATOR_COUNTING_ITERATOR_HPP
|
||||||
#define SPROUT_ITERATOR_COUNTING_ITERATOR_HPP
|
#define SPROUT_ITERATOR_COUNTING_ITERATOR_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/iterator/next.hpp>
|
#include <sprout/iterator/next.hpp>
|
||||||
#include <sprout/iterator/prev.hpp>
|
#include <sprout/iterator/prev.hpp>
|
||||||
#include <sprout/iterator/distance.hpp>
|
#include <sprout/iterator/distance.hpp>
|
||||||
|
@ -36,7 +36,7 @@ namespace sprout {
|
||||||
template<typename T, typename sprout::enabler_if<std::is_integral<T>::value>::type = sprout::enabler>
|
template<typename T, typename sprout::enabler_if<std::is_integral<T>::value>::type = sprout::enabler>
|
||||||
static SPROUT_CONSTEXPR T
|
static SPROUT_CONSTEXPR T
|
||||||
default_value() {
|
default_value() {
|
||||||
return std::numeric_limits<value_type>::max();
|
return sprout::numeric_limits<value_type>::max();
|
||||||
}
|
}
|
||||||
template<typename T, typename sprout::enabler_if<!std::is_integral<T>::value>::type = sprout::enabler>
|
template<typename T, typename sprout::enabler_if<!std::is_integral<T>::value>::type = sprout::enabler>
|
||||||
static SPROUT_CONSTEXPR T
|
static SPROUT_CONSTEXPR T
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
#define SPROUT_ITERATOR_GENERATOR_ITERATOR_HPP
|
#define SPROUT_ITERATOR_GENERATOR_ITERATOR_HPP
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <limits>
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/generator/functions.hpp>
|
#include <sprout/generator/functions.hpp>
|
||||||
#include <sprout/utility/swap.hpp>
|
#include <sprout/utility/swap.hpp>
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ namespace sprout {
|
||||||
{}
|
{}
|
||||||
explicit SPROUT_CONSTEXPR generator_iterator(
|
explicit SPROUT_CONSTEXPR generator_iterator(
|
||||||
generator_type const& gen,
|
generator_type const& gen,
|
||||||
difference_type index = std::numeric_limits<difference_type>::max()
|
difference_type index = sprout::numeric_limits<difference_type>::max()
|
||||||
)
|
)
|
||||||
: gen_(gen), index_(index)
|
: gen_(gen), index_(index)
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
#define SPROUT_ITERATOR_VALUE_ITERATOR_HPP
|
#define SPROUT_ITERATOR_VALUE_ITERATOR_HPP
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <limits>
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/iterator/next.hpp>
|
#include <sprout/iterator/next.hpp>
|
||||||
#include <sprout/iterator/prev.hpp>
|
#include <sprout/iterator/prev.hpp>
|
||||||
#include <sprout/iterator/distance.hpp>
|
#include <sprout/iterator/distance.hpp>
|
||||||
|
@ -62,7 +62,7 @@ namespace sprout {
|
||||||
value_iterator(value_iterator const&) = default;
|
value_iterator(value_iterator const&) = default;
|
||||||
explicit SPROUT_CONSTEXPR value_iterator(
|
explicit SPROUT_CONSTEXPR value_iterator(
|
||||||
typename sprout::value_holder<T>::param_type p,
|
typename sprout::value_holder<T>::param_type p,
|
||||||
difference_type index = std::numeric_limits<difference_type>::max()
|
difference_type index = sprout::numeric_limits<difference_type>::max()
|
||||||
)
|
)
|
||||||
: holder_(p), index_(index)
|
: holder_(p), index_(index)
|
||||||
{}
|
{}
|
||||||
|
|
277
sprout/limits.hpp
Normal file
277
sprout/limits.hpp
Normal file
|
@ -0,0 +1,277 @@
|
||||||
|
#ifndef SPROUT_LIMITS_HPP
|
||||||
|
#define SPROUT_LIMITS_HPP
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <climits>
|
||||||
|
#include <cfloat>
|
||||||
|
#include <limits>
|
||||||
|
#include <sprout/config.hpp>
|
||||||
|
|
||||||
|
namespace sprout {
|
||||||
|
//
|
||||||
|
// numeric_limits
|
||||||
|
//
|
||||||
|
#ifdef SPROUT_NO_CXX11_NUMERIC_LIMITS
|
||||||
|
namespace detail {
|
||||||
|
template<typename T>
|
||||||
|
class numeric_limits_base {
|
||||||
|
private:
|
||||||
|
typedef std::numeric_limits<T> impl_type;
|
||||||
|
public:
|
||||||
|
static SPROUT_CONSTEXPR bool is_specialized = impl_type::is_specialized;
|
||||||
|
|
||||||
|
static SPROUT_CONSTEXPR int digits = impl_type::digits;
|
||||||
|
static SPROUT_CONSTEXPR int digits10 = impl_type::digits10;
|
||||||
|
static SPROUT_CONSTEXPR int max_digits10 = impl_type::max_digits10;
|
||||||
|
static SPROUT_CONSTEXPR bool is_signed = impl_type::is_signed;
|
||||||
|
static SPROUT_CONSTEXPR bool is_integer = impl_type::is_integer;
|
||||||
|
static SPROUT_CONSTEXPR bool is_exact = impl_type::is_exact;
|
||||||
|
static SPROUT_CONSTEXPR int radix = impl_type::radix;
|
||||||
|
|
||||||
|
static SPROUT_CONSTEXPR int min_exponent = impl_type::min_exponent;
|
||||||
|
static SPROUT_CONSTEXPR int min_exponent10 = impl_type::min_exponent10;
|
||||||
|
static SPROUT_CONSTEXPR int max_exponent = impl_type::max_exponent;
|
||||||
|
static SPROUT_CONSTEXPR int max_exponent10 = impl_type::max_exponent10;
|
||||||
|
static SPROUT_CONSTEXPR bool has_infinity = impl_type::has_infinity;
|
||||||
|
static SPROUT_CONSTEXPR bool has_quiet_NaN = impl_type::has_quiet_NaN;
|
||||||
|
static SPROUT_CONSTEXPR bool has_signaling_NaN = impl_type::has_signaling_NaN;
|
||||||
|
static SPROUT_CONSTEXPR std::float_denorm_style has_denorm = impl_type::has_denorm;
|
||||||
|
static SPROUT_CONSTEXPR bool has_denorm_loss = impl_type::has_denorm_loss;
|
||||||
|
|
||||||
|
static SPROUT_CONSTEXPR bool is_iec559 = impl_type::is_iec559;
|
||||||
|
static SPROUT_CONSTEXPR bool is_bounded = impl_type::is_bounded;
|
||||||
|
static SPROUT_CONSTEXPR bool is_modulo = impl_type::is_modulo;
|
||||||
|
static SPROUT_CONSTEXPR bool traps = impl_type::traps;
|
||||||
|
static SPROUT_CONSTEXPR bool tinyness_before = impl_type::tinyness_before;
|
||||||
|
static SPROUT_CONSTEXPR std::float_round_style round_style = impl_type::round_style;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T, bool IsInitialized>
|
||||||
|
class numeric_limits_impl;
|
||||||
|
template<typename T>
|
||||||
|
class numeric_limits_impl<T, true>
|
||||||
|
: public sprout::detail::numeric_limits_base<T>
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
typedef std::numeric_limits<T> impl_type;
|
||||||
|
public:
|
||||||
|
static SPROUT_CONSTEXPR T min() SPROUT_NOEXCEPT {
|
||||||
|
return impl_type::min();
|
||||||
|
}
|
||||||
|
static SPROUT_CONSTEXPR T max() SPROUT_NOEXCEPT {
|
||||||
|
return impl_type::max();
|
||||||
|
}
|
||||||
|
static SPROUT_CONSTEXPR T lowest() SPROUT_NOEXCEPT {
|
||||||
|
return impl_type::lowest();
|
||||||
|
}
|
||||||
|
|
||||||
|
static SPROUT_CONSTEXPR T epsilon() SPROUT_NOEXCEPT {
|
||||||
|
return impl_type::epsilon();
|
||||||
|
}
|
||||||
|
static SPROUT_CONSTEXPR T round_error() SPROUT_NOEXCEPT {
|
||||||
|
return impl_type::round_error();
|
||||||
|
}
|
||||||
|
|
||||||
|
static SPROUT_CONSTEXPR T infinity() SPROUT_NOEXCEPT {
|
||||||
|
return impl_type::infinity();
|
||||||
|
}
|
||||||
|
static SPROUT_CONSTEXPR T quiet_NaN() SPROUT_NOEXCEPT {
|
||||||
|
return impl_type::quiet_NaN();
|
||||||
|
}
|
||||||
|
static SPROUT_CONSTEXPR T signaling_NaN() SPROUT_NOEXCEPT {
|
||||||
|
return impl_type::signaling_NaN();
|
||||||
|
}
|
||||||
|
static SPROUT_CONSTEXPR T denorm_min() SPROUT_NOEXCEPT {
|
||||||
|
return impl_type::denorm_min();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template<typename T>
|
||||||
|
class numeric_limits_impl<T, false>
|
||||||
|
: public sprout::detail::numeric_limits_base<T>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static SPROUT_CONSTEXPR T min() SPROUT_NOEXCEPT {
|
||||||
|
return T();
|
||||||
|
}
|
||||||
|
static SPROUT_CONSTEXPR T max() SPROUT_NOEXCEPT {
|
||||||
|
return T();
|
||||||
|
}
|
||||||
|
static SPROUT_CONSTEXPR T lowest() SPROUT_NOEXCEPT {
|
||||||
|
return T();
|
||||||
|
}
|
||||||
|
|
||||||
|
static SPROUT_CONSTEXPR T epsilon() SPROUT_NOEXCEPT {
|
||||||
|
return T();
|
||||||
|
}
|
||||||
|
static SPROUT_CONSTEXPR T round_error() SPROUT_NOEXCEPT {
|
||||||
|
return T();
|
||||||
|
}
|
||||||
|
|
||||||
|
static SPROUT_CONSTEXPR T infinity() SPROUT_NOEXCEPT {
|
||||||
|
return T();
|
||||||
|
}
|
||||||
|
static SPROUT_CONSTEXPR T quiet_NaN() SPROUT_NOEXCEPT {
|
||||||
|
return T();
|
||||||
|
}
|
||||||
|
static SPROUT_CONSTEXPR T signaling_NaN() SPROUT_NOEXCEPT {
|
||||||
|
return T();
|
||||||
|
}
|
||||||
|
static SPROUT_CONSTEXPR T denorm_min() SPROUT_NOEXCEPT {
|
||||||
|
return T();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class numeric_limits
|
||||||
|
: public sprout::detail::numeric_limits_impl<T, std::numeric_limits<T>::is_specialized>
|
||||||
|
{};
|
||||||
|
template<typename T>
|
||||||
|
class numeric_limits<T const>
|
||||||
|
: public sprout::numeric_limits<T>
|
||||||
|
{};
|
||||||
|
template<typename T>
|
||||||
|
class numeric_limits<T volatile>
|
||||||
|
: public sprout::numeric_limits<T>
|
||||||
|
{};
|
||||||
|
template<typename T>
|
||||||
|
class numeric_limits<T const volatile>
|
||||||
|
: public sprout::numeric_limits<T>
|
||||||
|
{};
|
||||||
|
|
||||||
|
#define SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(TYPE, MIN, MAX) \
|
||||||
|
template<> \
|
||||||
|
class numeric_limits<TYPE> \
|
||||||
|
: public sprout::detail::numeric_limits_base<TYPE> \
|
||||||
|
{ \
|
||||||
|
public: \
|
||||||
|
static SPROUT_CONSTEXPR TYPE min() SPROUT_NOEXCEPT { \
|
||||||
|
return MIN; \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR TYPE max() SPROUT_NOEXCEPT { \
|
||||||
|
return MAX; \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR TYPE lowest() SPROUT_NOEXCEPT { \
|
||||||
|
return min(); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
static SPROUT_CONSTEXPR TYPE epsilon() SPROUT_NOEXCEPT { \
|
||||||
|
return static_cast<TYPE>(0); \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR TYPE round_error() SPROUT_NOEXCEPT { \
|
||||||
|
return static_cast<TYPE>(0); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
static SPROUT_CONSTEXPR TYPE infinity() SPROUT_NOEXCEPT { \
|
||||||
|
return static_cast<TYPE>(0); \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR TYPE quiet_NaN() SPROUT_NOEXCEPT { \
|
||||||
|
return static_cast<TYPE>(0); \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR TYPE signaling_NaN() SPROUT_NOEXCEPT { \
|
||||||
|
return static_cast<TYPE>(0); \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR TYPE denorm_min() SPROUT_NOEXCEPT { \
|
||||||
|
return static_cast<TYPE>(0); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(bool, false, true);
|
||||||
|
|
||||||
|
SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(short, SHRT_MIN, SHRT_MAX);
|
||||||
|
SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(int, INT_MIN, INT_MAX);
|
||||||
|
SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(long, LONG_MIN, LONG_MAX);
|
||||||
|
SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(long long, LLONG_MIN, LLONG_MAX);
|
||||||
|
SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(unsigned short, static_cast<unsigned short>(0), USHRT_MAX);
|
||||||
|
SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(unsigned int, static_cast<unsigned int>(0), UINT_MAX);
|
||||||
|
SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(unsigned long, static_cast<unsigned long>(0), ULONG_MAX);
|
||||||
|
SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(unsigned long long, static_cast<unsigned long long>(0), ULLONG_MAX);
|
||||||
|
|
||||||
|
SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(signed char, SCHAR_MIN, SCHAR_MAX);
|
||||||
|
SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(unsigned char, static_cast<unsigned char>(0), UCHAR_MAX);
|
||||||
|
SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(
|
||||||
|
char16_t,
|
||||||
|
static_cast<char16_t>(sprout::numeric_limits<std::uint_least16_t>::min()),
|
||||||
|
static_cast<char16_t>(sprout::numeric_limits<std::uint_least16_t>::max())
|
||||||
|
);
|
||||||
|
SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(
|
||||||
|
char32_t,
|
||||||
|
static_cast<char16_t>(sprout::numeric_limits<std::uint_least32_t>::min()),
|
||||||
|
static_cast<char16_t>(sprout::numeric_limits<std::uint_least32_t>::max())
|
||||||
|
);
|
||||||
|
SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL(wchar_t, WCHAR_MIN, WCHAR_MAX);
|
||||||
|
#undef SPROUT_NUMERIC_LIMITS_INTEGRAL_SPECIALIZED_DECL
|
||||||
|
|
||||||
|
#define SPROUT_NUMERIC_LIMITS_FLOATING_POINT_SPECIALIZED_DECL(TYPE, MIN, MAX, EPS, RND, INF, QNAN, SNAN, DMIN) \
|
||||||
|
template<> \
|
||||||
|
class numeric_limits<TYPE> \
|
||||||
|
: public sprout::detail::numeric_limits_base<TYPE> \
|
||||||
|
{ \
|
||||||
|
public: \
|
||||||
|
static SPROUT_CONSTEXPR TYPE min() SPROUT_NOEXCEPT { \
|
||||||
|
return MIN; \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR TYPE max() SPROUT_NOEXCEPT { \
|
||||||
|
return MAX; \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR TYPE lowest() SPROUT_NOEXCEPT { \
|
||||||
|
return -max(); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
static SPROUT_CONSTEXPR TYPE epsilon() SPROUT_NOEXCEPT { \
|
||||||
|
return EPS; \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR TYPE round_error() SPROUT_NOEXCEPT { \
|
||||||
|
return RND; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
static SPROUT_CONSTEXPR TYPE infinity() SPROUT_NOEXCEPT { \
|
||||||
|
return INF; \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR TYPE quiet_NaN() SPROUT_NOEXCEPT { \
|
||||||
|
return QNAN; \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR TYPE signaling_NaN() SPROUT_NOEXCEPT { \
|
||||||
|
return SNAN; \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR TYPE denorm_min() SPROUT_NOEXCEPT { \
|
||||||
|
return DMIN; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
SPROUT_NUMERIC_LIMITS_FLOATING_POINT_SPECIALIZED_DECL(
|
||||||
|
float,
|
||||||
|
FLT_MIN, FLT_MAX,
|
||||||
|
FLT_EPSILON, 0.5F,
|
||||||
|
__builtin_huge_valf(), __builtin_nanf(""), __builtin_nansf(""), __FLT_DENORM_MIN__
|
||||||
|
);
|
||||||
|
SPROUT_NUMERIC_LIMITS_FLOATING_POINT_SPECIALIZED_DECL(
|
||||||
|
double,
|
||||||
|
DBL_MIN, DBL_MAX,
|
||||||
|
DBL_EPSILON, 0.5,
|
||||||
|
__builtin_huge_val(), __builtin_nan(""), __builtin_nans(""), __DBL_DENORM_MIN__
|
||||||
|
);
|
||||||
|
SPROUT_NUMERIC_LIMITS_FLOATING_POINT_SPECIALIZED_DECL(
|
||||||
|
long double,
|
||||||
|
LDBL_MIN, LDBL_MAX,
|
||||||
|
LDBL_EPSILON, 0.5L,
|
||||||
|
__builtin_huge_val(), __builtin_nan(""), __builtin_nans(""), __LDBL_DENORM_MIN__
|
||||||
|
);
|
||||||
|
#undef SPROUT_NUMERIC_LIMITS_FLOATING_POINT_SPECIALIZED_DECL
|
||||||
|
|
||||||
|
#else // #ifdef SPROUT_NO_CXX11_NUMERIC_LIMITS
|
||||||
|
|
||||||
|
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||||
|
template<typename T>
|
||||||
|
using numeric_limits = std::numeric_limits<T>;
|
||||||
|
#else // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||||
|
template<typename T>
|
||||||
|
class numeric_limits
|
||||||
|
: public std::numeric_limits<T>
|
||||||
|
{};
|
||||||
|
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||||
|
|
||||||
|
#endif // #ifdef SPROUT_NO_CXX11_NUMERIC_LIMITS
|
||||||
|
} // namespace sprout
|
||||||
|
|
||||||
|
#endif // #ifndef SPROUT_LIMITS_HPP
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_ACOS_HPP
|
#ifndef SPROUT_MATH_ACOS_HPP
|
||||||
#define SPROUT_MATH_ACOS_HPP
|
#define SPROUT_MATH_ACOS_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/constants.hpp>
|
#include <sprout/math/constants.hpp>
|
||||||
|
@ -28,7 +28,7 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
acos(FloatType x) {
|
acos(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: sprout::math::fabs(x) > 1 ? std::numeric_limits<FloatType>::quiet_NaN()
|
: sprout::math::fabs(x) > 1 ? sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::acos(x)
|
: std::acos(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_ACOSH_HPP
|
#ifndef SPROUT_MATH_ACOSH_HPP
|
||||||
#define SPROUT_MATH_ACOSH_HPP
|
#define SPROUT_MATH_ACOSH_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -27,8 +27,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
acosh(FloatType x) {
|
acosh(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x < 1 ? -std::numeric_limits<FloatType>::quiet_NaN()
|
: x < 1 ? -sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::acosh(x)
|
: std::acosh(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#define SPROUT_MATH_ASIN_HPP
|
#define SPROUT_MATH_ASIN_HPP
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/detail/pow.hpp>
|
#include <sprout/detail/pow.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
|
@ -77,7 +77,7 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
asin(FloatType x) {
|
asin(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: sprout::math::fabs(x) > 1 ? std::numeric_limits<FloatType>::quiet_NaN()
|
: sprout::math::fabs(x) > 1 ? sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::asin(x)
|
: std::asin(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_ASINH_HPP
|
#ifndef SPROUT_MATH_ASINH_HPP
|
||||||
#define SPROUT_MATH_ASINH_HPP
|
#define SPROUT_MATH_ASINH_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -27,8 +27,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
asinh(FloatType x) {
|
asinh(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? -std::numeric_limits<FloatType>::infinity()
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::asinh(x)
|
: std::asinh(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#define SPROUT_MATH_ATAN_HPP
|
#define SPROUT_MATH_ATAN_HPP
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/detail/pow.hpp>
|
#include <sprout/detail/pow.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
|
@ -43,8 +43,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
atan(FloatType x) {
|
atan(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? sprout::math::half_pi<FloatType>()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::math::half_pi<FloatType>()
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? -sprout::math::half_pi<FloatType>()
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? -sprout::math::half_pi<FloatType>()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::atan(x)
|
: std::atan(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_ATAN2_HPP
|
#ifndef SPROUT_MATH_ATAN2_HPP
|
||||||
#define SPROUT_MATH_ATAN2_HPP
|
#define SPROUT_MATH_ATAN2_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/constants.hpp>
|
#include <sprout/math/constants.hpp>
|
||||||
|
@ -37,20 +37,20 @@ namespace sprout {
|
||||||
atan2(FloatType y, FloatType x) {
|
atan2(FloatType y, FloatType x) {
|
||||||
return sprout::math::isnan(y)
|
return sprout::math::isnan(y)
|
||||||
? sprout::math::isnan(x)
|
? sprout::math::isnan(x)
|
||||||
? sprout::math::signbit(y) && sprout::math::signbit(x) ? -std::numeric_limits<FloatType>::quiet_NaN()
|
? sprout::math::signbit(y) && sprout::math::signbit(x) ? -sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
: std::numeric_limits<FloatType>::quiet_NaN()
|
: sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
: y
|
: y
|
||||||
: sprout::math::isnan(x) ? x
|
: sprout::math::isnan(x) ? x
|
||||||
: x == -std::numeric_limits<FloatType>::infinity()
|
: x == -sprout::numeric_limits<FloatType>::infinity()
|
||||||
? y == std::numeric_limits<FloatType>::infinity() ? sprout::math::three_quarters_pi<FloatType>()
|
? y == sprout::numeric_limits<FloatType>::infinity() ? sprout::math::three_quarters_pi<FloatType>()
|
||||||
: y == -std::numeric_limits<FloatType>::infinity() ? -sprout::math::three_quarters_pi<FloatType>()
|
: y == -sprout::numeric_limits<FloatType>::infinity() ? -sprout::math::three_quarters_pi<FloatType>()
|
||||||
: sprout::math::copysign(sprout::math::pi<FloatType>(), y)
|
: sprout::math::copysign(sprout::math::pi<FloatType>(), y)
|
||||||
: x == std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity()
|
||||||
? y == std::numeric_limits<FloatType>::infinity() ? sprout::math::quarter_pi<FloatType>()
|
? y == sprout::numeric_limits<FloatType>::infinity() ? sprout::math::quarter_pi<FloatType>()
|
||||||
: y == -std::numeric_limits<FloatType>::infinity() ? -sprout::math::quarter_pi<FloatType>()
|
: y == -sprout::numeric_limits<FloatType>::infinity() ? -sprout::math::quarter_pi<FloatType>()
|
||||||
: FloatType(0) * y
|
: FloatType(0) * y
|
||||||
: y == std::numeric_limits<FloatType>::infinity() ? sprout::math::half_pi<FloatType>()
|
: y == sprout::numeric_limits<FloatType>::infinity() ? sprout::math::half_pi<FloatType>()
|
||||||
: y == -std::numeric_limits<FloatType>::infinity() ? -sprout::math::half_pi<FloatType>()
|
: y == -sprout::numeric_limits<FloatType>::infinity() ? -sprout::math::half_pi<FloatType>()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::atan2(y, x)
|
: std::atan2(y, x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_ATANH_HPP
|
#ifndef SPROUT_MATH_ATANH_HPP
|
||||||
#define SPROUT_MATH_ATANH_HPP
|
#define SPROUT_MATH_ATANH_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -27,9 +27,9 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
atanh(FloatType x) {
|
atanh(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == 1 ? std::numeric_limits<FloatType>::infinity()
|
: x == 1 ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == -1 ? -std::numeric_limits<FloatType>::infinity()
|
: x == -1 ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
: sprout::math::fabs(x) > 1 ? -std::numeric_limits<FloatType>::quiet_NaN()
|
: sprout::math::fabs(x) > 1 ? -sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::atanh(x)
|
: std::atanh(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_CBRT_HPP
|
#ifndef SPROUT_MATH_CBRT_HPP
|
||||||
#define SPROUT_MATH_CBRT_HPP
|
#define SPROUT_MATH_CBRT_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/constants.hpp>
|
#include <sprout/math/constants.hpp>
|
||||||
|
@ -29,8 +29,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
cbrt(FloatType x) {
|
cbrt(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? -std::numeric_limits<FloatType>::infinity()
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::cbrt(x)
|
: std::cbrt(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
#define SPROUT_MATH_CEIL_HPP
|
#define SPROUT_MATH_CEIL_HPP
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -37,13 +37,13 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
ceil(FloatType x) {
|
ceil(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? -std::numeric_limits<FloatType>::infinity()
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::ceil(x)
|
: std::ceil(x)
|
||||||
#else
|
#else
|
||||||
: x == 0 ? x
|
: x == 0 ? x
|
||||||
: std::numeric_limits<std::uintmax_t>::max() < x || std::numeric_limits<std::uintmax_t>::max() < -x
|
: sprout::numeric_limits<std::uintmax_t>::max() < x || sprout::numeric_limits<std::uintmax_t>::max() < -x
|
||||||
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("ceil: large float rounding."), x)
|
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("ceil: large float rounding."), x)
|
||||||
: static_cast<FloatType>(sprout::math::detail::ceil_impl(static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x)))
|
: static_cast<FloatType>(sprout::math::detail::ceil_impl(static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x)))
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_COPYSIGN_HPP
|
#ifndef SPROUT_MATH_COPYSIGN_HPP
|
||||||
#define SPROUT_MATH_COPYSIGN_HPP
|
#define SPROUT_MATH_COPYSIGN_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
#include <sprout/math/signbit.hpp>
|
#include <sprout/math/signbit.hpp>
|
||||||
|
@ -25,8 +25,8 @@ namespace sprout {
|
||||||
: FloatType(0)
|
: FloatType(0)
|
||||||
: sprout::math::isnan(x)
|
: sprout::math::isnan(x)
|
||||||
? sprout::math::isnan(y) ? y
|
? sprout::math::isnan(y) ? y
|
||||||
: sprout::math::signbit(y) ? -std::numeric_limits<FloatType>::quiet_NaN()
|
: sprout::math::signbit(y) ? -sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
: std::numeric_limits<FloatType>::quiet_NaN()
|
: sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
: sprout::math::signbit(y) != sprout::math::signbit(x) ? -x
|
: sprout::math::signbit(y) != sprout::math::signbit(x) ? -x
|
||||||
: x
|
: x
|
||||||
;
|
;
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#define SPROUT_MATH_COS_HPP
|
#define SPROUT_MATH_COS_HPP
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/detail/pow.hpp>
|
#include <sprout/detail/pow.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
|
@ -38,6 +38,7 @@ namespace sprout {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// !!!
|
||||||
// template<typename T>
|
// template<typename T>
|
||||||
// inline SPROUT_CONSTEXPR T
|
// inline SPROUT_CONSTEXPR T
|
||||||
// cos_impl_2(T x) {
|
// cos_impl_2(T x) {
|
||||||
|
@ -70,8 +71,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
cos(FloatType x) {
|
cos(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() || x == -std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() || x == -sprout::numeric_limits<FloatType>::infinity()
|
||||||
? -std::numeric_limits<FloatType>::quiet_NaN()
|
? -sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::cos(x)
|
: std::cos(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#define SPROUT_MATH_COSH_HPP
|
#define SPROUT_MATH_COSH_HPP
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -32,8 +32,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
cosh(FloatType x) {
|
cosh(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() || x == -std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() || x == -sprout::numeric_limits<FloatType>::infinity()
|
||||||
? std::numeric_limits<FloatType>::infinity()
|
? sprout::numeric_limits<FloatType>::infinity()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::cosh(x)
|
: std::cosh(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_EQUAL_TO_HPP
|
#ifndef SPROUT_MATH_EQUAL_TO_HPP
|
||||||
#define SPROUT_MATH_EQUAL_TO_HPP
|
#define SPROUT_MATH_EQUAL_TO_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/algorithm/max.hpp>
|
#include <sprout/algorithm/max.hpp>
|
||||||
#include <sprout/math/fabs.hpp>
|
#include <sprout/math/fabs.hpp>
|
||||||
#include <sprout/type_traits/arithmetic_promote.hpp>
|
#include <sprout/type_traits/arithmetic_promote.hpp>
|
||||||
|
@ -23,7 +23,7 @@ namespace sprout {
|
||||||
equal_to_impl(FloatType x, FloatType y) {
|
equal_to_impl(FloatType x, FloatType y) {
|
||||||
return x == y
|
return x == y
|
||||||
|| sprout::fabs(x - y)
|
|| sprout::fabs(x - y)
|
||||||
<= std::numeric_limits<FloatType>::epsilon() * sprout::math::detail::max3(sprout::fabs(x), sprout::fabs(y), FloatType(1))
|
<= sprout::numeric_limits<FloatType>::epsilon() * sprout::math::detail::max3(sprout::fabs(x), sprout::fabs(y), FloatType(1))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_ERF_HPP
|
#ifndef SPROUT_MATH_ERF_HPP
|
||||||
#define SPROUT_MATH_ERF_HPP
|
#define SPROUT_MATH_ERF_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/detail/pow.hpp>
|
#include <sprout/detail/pow.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
|
@ -126,8 +126,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
erf(FloatType x) {
|
erf(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? FloatType(1)
|
: x == sprout::numeric_limits<FloatType>::infinity() ? FloatType(1)
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? FloatType(-1)
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? FloatType(-1)
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::erf(x)
|
: std::erf(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -25,8 +25,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
erfc(FloatType x) {
|
erfc(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? FloatType(0)
|
: x == sprout::numeric_limits<FloatType>::infinity() ? FloatType(0)
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? FloatType(2)
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? FloatType(2)
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::erfc(x)
|
: std::erfc(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#define SPROUT_MATH_EXP_HPP
|
#define SPROUT_MATH_EXP_HPP
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/detail/pow.hpp>
|
#include <sprout/detail/pow.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
|
@ -39,8 +39,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
exp(FloatType x) {
|
exp(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? FloatType(0)
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? FloatType(0)
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::exp(x)
|
: std::exp(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_EXP10_HPP
|
#ifndef SPROUT_MATH_EXP10_HPP
|
||||||
#define SPROUT_MATH_EXP10_HPP
|
#define SPROUT_MATH_EXP10_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/constants.hpp>
|
#include <sprout/math/constants.hpp>
|
||||||
|
@ -27,8 +27,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
exp10(FloatType x) {
|
exp10(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? FloatType(0)
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? FloatType(0)
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == 0 ? FloatType(1)
|
: x == 0 ? FloatType(1)
|
||||||
: static_cast<FloatType>(sprout::math::detail::exp10_impl(static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x)))
|
: static_cast<FloatType>(sprout::math::detail::exp10_impl(static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x)))
|
||||||
;
|
;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_EXP2_HPP
|
#ifndef SPROUT_MATH_EXP2_HPP
|
||||||
#define SPROUT_MATH_EXP2_HPP
|
#define SPROUT_MATH_EXP2_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/constants.hpp>
|
#include <sprout/math/constants.hpp>
|
||||||
|
@ -27,8 +27,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
exp2(FloatType x) {
|
exp2(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? FloatType(0)
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? FloatType(0)
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::exp2(x)
|
: std::exp2(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_EXPM1_HPP
|
#ifndef SPROUT_MATH_EXPM1_HPP
|
||||||
#define SPROUT_MATH_EXPM1_HPP
|
#define SPROUT_MATH_EXPM1_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/constants.hpp>
|
#include <sprout/math/constants.hpp>
|
||||||
|
@ -28,8 +28,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
expm1(FloatType x) {
|
expm1(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? FloatType(-1)
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? FloatType(-1)
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::expm1(x)
|
: std::expm1(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace sprout {
|
||||||
>
|
>
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
fabs(FloatType x) {
|
fabs(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? std::numeric_limits<FloatType>::quiet_NaN()
|
return sprout::math::isnan(x) ? sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
: x == 0 ? FloatType(0)
|
: x == 0 ? FloatType(0)
|
||||||
: sprout::math::copysign(x, FloatType(0))
|
: sprout::math::copysign(x, FloatType(0))
|
||||||
;
|
;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_FDIM_HPP
|
#ifndef SPROUT_MATH_FDIM_HPP
|
||||||
#define SPROUT_MATH_FDIM_HPP
|
#define SPROUT_MATH_FDIM_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
#include <sprout/type_traits/float_promote.hpp>
|
#include <sprout/type_traits/float_promote.hpp>
|
||||||
|
@ -20,10 +20,10 @@ namespace sprout {
|
||||||
fdim(FloatType x, FloatType y) {
|
fdim(FloatType x, FloatType y) {
|
||||||
return sprout::math::isnan(y) ? y
|
return sprout::math::isnan(y) ? y
|
||||||
: sprout::math::isnan(x) ? x
|
: sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? FloatType(0)
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? FloatType(0)
|
||||||
: y == std::numeric_limits<FloatType>::infinity() ? FloatType(0)
|
: y == sprout::numeric_limits<FloatType>::infinity() ? FloatType(0)
|
||||||
: y == -std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: y == -sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::fdim(x, y)
|
: std::fdim(x, y)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_FLOAT2_EXPONENT_HPP
|
#ifndef SPROUT_MATH_FLOAT2_EXPONENT_HPP
|
||||||
#define SPROUT_MATH_FLOAT2_EXPONENT_HPP
|
#define SPROUT_MATH_FLOAT2_EXPONENT_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/ilogb2.hpp>
|
#include <sprout/math/ilogb2.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -20,7 +20,7 @@ namespace sprout {
|
||||||
float2_exponent(FloatType x) {
|
float2_exponent(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? 0
|
return sprout::math::isnan(x) ? 0
|
||||||
: x == 0 ? 0
|
: x == 0 ? 0
|
||||||
: x == std::numeric_limits<FloatType>::infinity() || x == -std::numeric_limits<FloatType>::infinity() ? 0
|
: x == sprout::numeric_limits<FloatType>::infinity() || x == -sprout::numeric_limits<FloatType>::infinity() ? 0
|
||||||
: sprout::math::ilogb2(x) + 1
|
: sprout::math::ilogb2(x) + 1
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_FLOAT2_SIG_EXP_HPP
|
#ifndef SPROUT_MATH_FLOAT2_SIG_EXP_HPP
|
||||||
#define SPROUT_MATH_FLOAT2_SIG_EXP_HPP
|
#define SPROUT_MATH_FLOAT2_SIG_EXP_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/detail/pow.hpp>
|
#include <sprout/detail/pow.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -29,8 +29,8 @@ namespace sprout {
|
||||||
float2_sig_exp(FloatType x) {
|
float2_sig_exp(FloatType x) {
|
||||||
typedef sprout::pair<FloatType, int> type;
|
typedef sprout::pair<FloatType, int> type;
|
||||||
return sprout::math::isnan(x) ? type(x, 0)
|
return sprout::math::isnan(x) ? type(x, 0)
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? type(std::numeric_limits<FloatType>::infinity(), 0)
|
: x == sprout::numeric_limits<FloatType>::infinity() ? type(sprout::numeric_limits<FloatType>::infinity(), 0)
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? type(-std::numeric_limits<FloatType>::infinity(), 0)
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? type(-sprout::numeric_limits<FloatType>::infinity(), 0)
|
||||||
: x == 0 ? type(x, 0)
|
: x == 0 ? type(x, 0)
|
||||||
: sprout::math::detail::float2_sig_exp_impl(x, sprout::math::ilogb2(x) + 1)
|
: sprout::math::detail::float2_sig_exp_impl(x, sprout::math::ilogb2(x) + 1)
|
||||||
;
|
;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_FLOAT2_SIGNIFICAND_HPP
|
#ifndef SPROUT_MATH_FLOAT2_SIGNIFICAND_HPP
|
||||||
#define SPROUT_MATH_FLOAT2_SIGNIFICAND_HPP
|
#define SPROUT_MATH_FLOAT2_SIGNIFICAND_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/detail/pow.hpp>
|
#include <sprout/detail/pow.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -20,8 +20,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
float2_significand(FloatType x) {
|
float2_significand(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? -std::numeric_limits<FloatType>::infinity()
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == 0 ? x
|
: x == 0 ? x
|
||||||
: x / sprout::detail::pow_n(FloatType(2), sprout::float2_exponent(x))
|
: x / sprout::detail::pow_n(FloatType(2), sprout::float2_exponent(x))
|
||||||
;
|
;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_FLOAT_EXPONENT_HPP
|
#ifndef SPROUT_MATH_FLOAT_EXPONENT_HPP
|
||||||
#define SPROUT_MATH_FLOAT_EXPONENT_HPP
|
#define SPROUT_MATH_FLOAT_EXPONENT_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/ilogb.hpp>
|
#include <sprout/math/ilogb.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -20,7 +20,7 @@ namespace sprout {
|
||||||
float_exponent(FloatType x) {
|
float_exponent(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? 0
|
return sprout::math::isnan(x) ? 0
|
||||||
: x == 0 ? 0
|
: x == 0 ? 0
|
||||||
: x == std::numeric_limits<FloatType>::infinity() || x == -std::numeric_limits<FloatType>::infinity() ? 0
|
: x == sprout::numeric_limits<FloatType>::infinity() || x == -sprout::numeric_limits<FloatType>::infinity() ? 0
|
||||||
: sprout::math::ilogb(x) + 1
|
: sprout::math::ilogb(x) + 1
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_FLOAT_SIG_EXP_HPP
|
#ifndef SPROUT_MATH_FLOAT_SIG_EXP_HPP
|
||||||
#define SPROUT_MATH_FLOAT_SIG_EXP_HPP
|
#define SPROUT_MATH_FLOAT_SIG_EXP_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/detail/pow.hpp>
|
#include <sprout/detail/pow.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -18,7 +18,7 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR sprout::pair<T, int>
|
inline SPROUT_CONSTEXPR sprout::pair<T, int>
|
||||||
float_sig_exp_impl(T x, int exp) {
|
float_sig_exp_impl(T x, int exp) {
|
||||||
typedef sprout::pair<T, int> type;
|
typedef sprout::pair<T, int> type;
|
||||||
return type(x / sprout::detail::pow_n(T(std::numeric_limits<T>::radix), exp), exp);
|
return type(x / sprout::detail::pow_n(T(sprout::numeric_limits<T>::radix), exp), exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<
|
template<
|
||||||
|
@ -29,8 +29,8 @@ namespace sprout {
|
||||||
float_sig_exp(FloatType x) {
|
float_sig_exp(FloatType x) {
|
||||||
typedef sprout::pair<FloatType, int> type;
|
typedef sprout::pair<FloatType, int> type;
|
||||||
return sprout::math::isnan(x) ? type(x, 0)
|
return sprout::math::isnan(x) ? type(x, 0)
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? type(std::numeric_limits<FloatType>::infinity(), 0)
|
: x == sprout::numeric_limits<FloatType>::infinity() ? type(sprout::numeric_limits<FloatType>::infinity(), 0)
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? type(-std::numeric_limits<FloatType>::infinity(), 0)
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? type(-sprout::numeric_limits<FloatType>::infinity(), 0)
|
||||||
: x == 0 ? type(x, 0)
|
: x == 0 ? type(x, 0)
|
||||||
: sprout::math::detail::float_sig_exp_impl(x, sprout::math::ilogb(x) + 1)
|
: sprout::math::detail::float_sig_exp_impl(x, sprout::math::ilogb(x) + 1)
|
||||||
;
|
;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_FLOAT_SIGNIFICAND_HPP
|
#ifndef SPROUT_MATH_FLOAT_SIGNIFICAND_HPP
|
||||||
#define SPROUT_MATH_FLOAT_SIGNIFICAND_HPP
|
#define SPROUT_MATH_FLOAT_SIGNIFICAND_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/detail/pow.hpp>
|
#include <sprout/detail/pow.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -20,10 +20,10 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
float_significand(FloatType x) {
|
float_significand(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? -std::numeric_limits<FloatType>::infinity()
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == 0 ? x
|
: x == 0 ? x
|
||||||
: x / sprout::detail::pow_n(FloatType(std::numeric_limits<FloatType>::radix), sprout::float_exponent(x))
|
: x / sprout::detail::pow_n(FloatType(sprout::numeric_limits<FloatType>::radix), sprout::float_exponent(x))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
template<
|
template<
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
#define SPROUT_MATH_FLOOR_HPP
|
#define SPROUT_MATH_FLOOR_HPP
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -37,13 +37,13 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
floor(FloatType x) {
|
floor(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? -std::numeric_limits<FloatType>::infinity()
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::floor(x)
|
: std::floor(x)
|
||||||
#else
|
#else
|
||||||
: x == 0 ? x
|
: x == 0 ? x
|
||||||
: std::numeric_limits<std::uintmax_t>::max() < x || std::numeric_limits<std::uintmax_t>::max() < -x
|
: sprout::numeric_limits<std::uintmax_t>::max() < x || sprout::numeric_limits<std::uintmax_t>::max() < -x
|
||||||
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("floor: large float rounding."), x)
|
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("floor: large float rounding."), x)
|
||||||
: static_cast<FloatType>(sprout::math::detail::floor_impl(static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x)))
|
: static_cast<FloatType>(sprout::math::detail::floor_impl(static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x)))
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_FMA_HPP
|
#ifndef SPROUT_MATH_FMA_HPP
|
||||||
#define SPROUT_MATH_FMA_HPP
|
#define SPROUT_MATH_FMA_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
#include <sprout/math/isinf.hpp>
|
#include <sprout/math/isinf.hpp>
|
||||||
|
@ -23,10 +23,10 @@ namespace sprout {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: sprout::math::isnan(y) ? y
|
: sprout::math::isnan(y) ? y
|
||||||
: sprout::math::isnan(z) ? z
|
: sprout::math::isnan(z) ? z
|
||||||
: sprout::math::isinf(x) && y == 0 ? std::numeric_limits<FloatType>::quiet_NaN()
|
: sprout::math::isinf(x) && y == 0 ? sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
: sprout::math::isinf(y) && x == 0 ? std::numeric_limits<FloatType>::quiet_NaN()
|
: sprout::math::isinf(y) && x == 0 ? sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
: (sprout::math::isinf(x) || sprout::math::isinf(y)) && sprout::math::isinf(z) && (sprout::math::signbit(x) ^ sprout::math::signbit(y) ^ sprout::math::signbit(z))
|
: (sprout::math::isinf(x) || sprout::math::isinf(y)) && sprout::math::isinf(z) && (sprout::math::signbit(x) ^ sprout::math::signbit(y) ^ sprout::math::signbit(z))
|
||||||
? std::numeric_limits<FloatType>::quiet_NaN()
|
? sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::fma(x, y, z)
|
: std::fma(x, y, z)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_FMAX_HPP
|
#ifndef SPROUT_MATH_FMAX_HPP
|
||||||
#define SPROUT_MATH_FMAX_HPP
|
#define SPROUT_MATH_FMAX_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
#include <sprout/type_traits/float_promote.hpp>
|
#include <sprout/type_traits/float_promote.hpp>
|
||||||
|
@ -20,10 +20,10 @@ namespace sprout {
|
||||||
fmax(FloatType x, FloatType y) {
|
fmax(FloatType x, FloatType y) {
|
||||||
return sprout::math::isnan(y) ? x
|
return sprout::math::isnan(y) ? x
|
||||||
: sprout::math::isnan(x) ? y
|
: sprout::math::isnan(x) ? y
|
||||||
: y == -std::numeric_limits<FloatType>::infinity() ? x
|
: y == -sprout::numeric_limits<FloatType>::infinity() ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? x
|
: x == sprout::numeric_limits<FloatType>::infinity() ? x
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? y
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? y
|
||||||
: y == std::numeric_limits<FloatType>::infinity() ? y
|
: y == sprout::numeric_limits<FloatType>::infinity() ? y
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: x == 0 && y == 0 ? x
|
: x == 0 && y == 0 ? x
|
||||||
: std::fmax(x, y)
|
: std::fmax(x, y)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_FMIN_HPP
|
#ifndef SPROUT_MATH_FMIN_HPP
|
||||||
#define SPROUT_MATH_FMIN_HPP
|
#define SPROUT_MATH_FMIN_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
#include <sprout/type_traits/float_promote.hpp>
|
#include <sprout/type_traits/float_promote.hpp>
|
||||||
|
@ -20,10 +20,10 @@ namespace sprout {
|
||||||
fmin(FloatType x, FloatType y) {
|
fmin(FloatType x, FloatType y) {
|
||||||
return sprout::math::isnan(y) ? x
|
return sprout::math::isnan(y) ? x
|
||||||
: sprout::math::isnan(x) ? y
|
: sprout::math::isnan(x) ? y
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? x
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? x
|
||||||
: y == std::numeric_limits<FloatType>::infinity() ? x
|
: y == sprout::numeric_limits<FloatType>::infinity() ? x
|
||||||
: y == -std::numeric_limits<FloatType>::infinity() ? y
|
: y == -sprout::numeric_limits<FloatType>::infinity() ? y
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? y
|
: x == sprout::numeric_limits<FloatType>::infinity() ? y
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: x == 0 && y == 0 ? x
|
: x == 0 && y == 0 ? x
|
||||||
: std::fmin(x, y)
|
: std::fmin(x, y)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_FMOD_HPP
|
#ifndef SPROUT_MATH_FMOD_HPP
|
||||||
#define SPROUT_MATH_FMOD_HPP
|
#define SPROUT_MATH_FMOD_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -73,14 +73,14 @@ namespace sprout {
|
||||||
fmod(FloatType x, FloatType y) {
|
fmod(FloatType x, FloatType y) {
|
||||||
return sprout::math::isnan(y)
|
return sprout::math::isnan(y)
|
||||||
? sprout::math::isnan(x)
|
? sprout::math::isnan(x)
|
||||||
? sprout::math::signbit(y) || sprout::math::signbit(x) ? -std::numeric_limits<FloatType>::quiet_NaN()
|
? sprout::math::signbit(y) || sprout::math::signbit(x) ? -sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
: std::numeric_limits<FloatType>::quiet_NaN()
|
: sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
: y
|
: y
|
||||||
: sprout::math::isnan(x) ? x
|
: sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() || x == -std::numeric_limits<FloatType>::infinity() || y == 0
|
: x == sprout::numeric_limits<FloatType>::infinity() || x == -sprout::numeric_limits<FloatType>::infinity() || y == 0
|
||||||
? -std::numeric_limits<FloatType>::quiet_NaN()
|
? -sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
: x == 0 ? x
|
: x == 0 ? x
|
||||||
: y == std::numeric_limits<FloatType>::infinity() || y == -std::numeric_limits<FloatType>::infinity() ? x
|
: y == sprout::numeric_limits<FloatType>::infinity() || y == -sprout::numeric_limits<FloatType>::infinity() ? x
|
||||||
: static_cast<FloatType>(sprout::math::detail::fmod_impl(
|
: static_cast<FloatType>(sprout::math::detail::fmod_impl(
|
||||||
static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x),
|
static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x),
|
||||||
static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(y)
|
static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(y)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_FRAC_INT_HPP
|
#ifndef SPROUT_MATH_FRAC_INT_HPP
|
||||||
#define SPROUT_MATH_FRAC_INT_HPP
|
#define SPROUT_MATH_FRAC_INT_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/copysign.hpp>
|
#include <sprout/math/copysign.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -19,7 +19,7 @@ namespace sprout {
|
||||||
frac_int_impl(T x, T ipart) {
|
frac_int_impl(T x, T ipart) {
|
||||||
typedef sprout::pair<T, T> type;
|
typedef sprout::pair<T, T> type;
|
||||||
return sprout::math::isnan(x) ? type(x, ipart)
|
return sprout::math::isnan(x) ? type(x, ipart)
|
||||||
: x == std::numeric_limits<T>::infinity() || x == -std::numeric_limits<T>::infinity() ? type(sprout::math::copysign(T(0), x), ipart)
|
: x == sprout::numeric_limits<T>::infinity() || x == -sprout::numeric_limits<T>::infinity() ? type(sprout::math::copysign(T(0), x), ipart)
|
||||||
: x == 0 ? type(x, ipart)
|
: x == 0 ? type(x, ipart)
|
||||||
: x == ipart ? type(T(0) * x, ipart)
|
: x == ipart ? type(T(0) * x, ipart)
|
||||||
: type(sprout::math::copysign(x - ipart, x), ipart)
|
: type(sprout::math::copysign(x - ipart, x), ipart)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_FRACTIONAL_PART_HPP
|
#ifndef SPROUT_MATH_FRACTIONAL_PART_HPP
|
||||||
#define SPROUT_MATH_FRACTIONAL_PART_HPP
|
#define SPROUT_MATH_FRACTIONAL_PART_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/copysign.hpp>
|
#include <sprout/math/copysign.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -28,7 +28,7 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
fractional_part(FloatType x) {
|
fractional_part(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() || x == -std::numeric_limits<FloatType>::infinity() ? sprout::math::copysign(FloatType(0), x)
|
: x == sprout::numeric_limits<FloatType>::infinity() || x == -sprout::numeric_limits<FloatType>::infinity() ? sprout::math::copysign(FloatType(0), x)
|
||||||
: x == 0 ? x
|
: x == 0 ? x
|
||||||
: sprout::math::detail::fractional_part_impl(x, sprout::integer_part(x))
|
: sprout::math::detail::fractional_part_impl(x, sprout::integer_part(x))
|
||||||
;
|
;
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#define SPROUT_MATH_GCD_HPP
|
#define SPROUT_MATH_GCD_HPP
|
||||||
|
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <limits>
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/array/array.hpp>
|
#include <sprout/array/array.hpp>
|
||||||
#include <sprout/cstdlib/abs.hpp>
|
#include <sprout/cstdlib/abs.hpp>
|
||||||
#ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE
|
#ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE
|
||||||
|
@ -158,7 +158,7 @@ namespace sprout {
|
||||||
struct gcd_optimal_evaluator {
|
struct gcd_optimal_evaluator {
|
||||||
public:
|
public:
|
||||||
SPROUT_CONSTEXPR T operator()(T const& a, T const& b) const {
|
SPROUT_CONSTEXPR T operator()(T const& a, T const& b) const {
|
||||||
typedef std::numeric_limits<T> limits_type;
|
typedef sprout::numeric_limits<T> limits_type;
|
||||||
typedef sprout::math::detail::gcd_optimal_evaluator_helper_t<
|
typedef sprout::math::detail::gcd_optimal_evaluator_helper_t<
|
||||||
T, limits_type::is_specialized, limits_type::is_signed
|
T, limits_type::is_specialized, limits_type::is_signed
|
||||||
> helper_type;
|
> helper_type;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_HYPOT_HPP
|
#ifndef SPROUT_MATH_HYPOT_HPP
|
||||||
#define SPROUT_MATH_HYPOT_HPP
|
#define SPROUT_MATH_HYPOT_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -41,10 +41,10 @@ namespace sprout {
|
||||||
>
|
>
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
hypot(FloatType x, FloatType y) {
|
hypot(FloatType x, FloatType y) {
|
||||||
return y == std::numeric_limits<FloatType>::infinity() || y == -std::numeric_limits<FloatType>::infinity()
|
return y == sprout::numeric_limits<FloatType>::infinity() || y == -sprout::numeric_limits<FloatType>::infinity()
|
||||||
? std::numeric_limits<FloatType>::infinity()
|
? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == std::numeric_limits<FloatType>::infinity() || x == -std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() || x == -sprout::numeric_limits<FloatType>::infinity()
|
||||||
? std::numeric_limits<FloatType>::infinity()
|
? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: sprout::math::isnan(y) ? y
|
: sprout::math::isnan(y) ? y
|
||||||
: sprout::math::isnan(x) ? x
|
: sprout::math::isnan(x) ? x
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef SPROUT_MATH_ICEIL_HPP
|
#ifndef SPROUT_MATH_ICEIL_HPP
|
||||||
#define SPROUT_MATH_ICEIL_HPP
|
#define SPROUT_MATH_ICEIL_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
#include <sprout/math/isinf.hpp>
|
#include <sprout/math/isinf.hpp>
|
||||||
|
@ -22,7 +22,7 @@ namespace sprout {
|
||||||
template<typename To, typename FloatType>
|
template<typename To, typename FloatType>
|
||||||
inline SPROUT_CONSTEXPR To
|
inline SPROUT_CONSTEXPR To
|
||||||
iceil_impl(FloatType x) {
|
iceil_impl(FloatType x) {
|
||||||
return std::numeric_limits<To>::max() < x || std::numeric_limits<To>::min() > x
|
return sprout::numeric_limits<To>::max() < x || sprout::numeric_limits<To>::min() > x
|
||||||
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("iceil: large float rounding."), static_cast<To>(x))
|
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("iceil: large float rounding."), static_cast<To>(x))
|
||||||
: static_cast<To>(x)
|
: static_cast<To>(x)
|
||||||
;
|
;
|
||||||
|
@ -34,7 +34,7 @@ namespace sprout {
|
||||||
>
|
>
|
||||||
inline SPROUT_CONSTEXPR To
|
inline SPROUT_CONSTEXPR To
|
||||||
iceil(FloatType x) {
|
iceil(FloatType x) {
|
||||||
return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits<To>::min()
|
return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits<To>::min()
|
||||||
: sprout::math::detail::iceil_impl<To>(sprout::math::ceil(x))
|
: sprout::math::detail::iceil_impl<To>(sprout::math::ceil(x))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -53,9 +53,9 @@ namespace sprout {
|
||||||
>
|
>
|
||||||
inline SPROUT_CONSTEXPR To
|
inline SPROUT_CONSTEXPR To
|
||||||
iceil(FloatType x) {
|
iceil(FloatType x) {
|
||||||
return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits<To>::min()
|
return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits<To>::min()
|
||||||
: x == 0 ? To(0)
|
: x == 0 ? To(0)
|
||||||
: std::numeric_limits<To>::max() < x || std::numeric_limits<To>::min() > x
|
: sprout::numeric_limits<To>::max() < x || sprout::numeric_limits<To>::min() > x
|
||||||
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("iceil: large float rounding."), static_cast<To>(x))
|
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("iceil: large float rounding."), static_cast<To>(x))
|
||||||
: sprout::math::detail::iceil_impl(x, static_cast<To>(x))
|
: sprout::math::detail::iceil_impl(x, static_cast<To>(x))
|
||||||
;
|
;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef SPROUT_MATH_IFLOOR_HPP
|
#ifndef SPROUT_MATH_IFLOOR_HPP
|
||||||
#define SPROUT_MATH_IFLOOR_HPP
|
#define SPROUT_MATH_IFLOOR_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
#include <sprout/math/isinf.hpp>
|
#include <sprout/math/isinf.hpp>
|
||||||
|
@ -22,7 +22,7 @@ namespace sprout {
|
||||||
template<typename To, typename FloatType>
|
template<typename To, typename FloatType>
|
||||||
inline SPROUT_CONSTEXPR To
|
inline SPROUT_CONSTEXPR To
|
||||||
ifloor_impl(FloatType x) {
|
ifloor_impl(FloatType x) {
|
||||||
return std::numeric_limits<To>::max() < x || std::numeric_limits<To>::min() > x
|
return sprout::numeric_limits<To>::max() < x || sprout::numeric_limits<To>::min() > x
|
||||||
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("ifloor: large float rounding."), static_cast<To>(x))
|
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("ifloor: large float rounding."), static_cast<To>(x))
|
||||||
: static_cast<To>(x)
|
: static_cast<To>(x)
|
||||||
;
|
;
|
||||||
|
@ -34,7 +34,7 @@ namespace sprout {
|
||||||
>
|
>
|
||||||
inline SPROUT_CONSTEXPR To
|
inline SPROUT_CONSTEXPR To
|
||||||
ifloor(FloatType x) {
|
ifloor(FloatType x) {
|
||||||
return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits<To>::min()
|
return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits<To>::min()
|
||||||
: sprout::math::detail::ifloor_impl<To>(sprout::math::floor(x))
|
: sprout::math::detail::ifloor_impl<To>(sprout::math::floor(x))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -53,9 +53,9 @@ namespace sprout {
|
||||||
>
|
>
|
||||||
inline SPROUT_CONSTEXPR To
|
inline SPROUT_CONSTEXPR To
|
||||||
ifloor(FloatType x) {
|
ifloor(FloatType x) {
|
||||||
return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits<To>::min()
|
return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits<To>::min()
|
||||||
: x == 0 ? To(0)
|
: x == 0 ? To(0)
|
||||||
: std::numeric_limits<To>::max() < x || std::numeric_limits<To>::min() > x
|
: sprout::numeric_limits<To>::max() < x || sprout::numeric_limits<To>::min() > x
|
||||||
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("ifloor: large float rounding."), static_cast<To>(x))
|
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("ifloor: large float rounding."), static_cast<To>(x))
|
||||||
: sprout::math::detail::ifloor_impl(x, static_cast<To>(x))
|
: sprout::math::detail::ifloor_impl(x, static_cast<To>(x))
|
||||||
;
|
;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_INTEGER_PART_HPP
|
#ifndef SPROUT_MATH_INTEGER_PART_HPP
|
||||||
#define SPROUT_MATH_INTEGER_PART_HPP
|
#define SPROUT_MATH_INTEGER_PART_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
#include <sprout/math/trunc.hpp>
|
#include <sprout/math/trunc.hpp>
|
||||||
|
@ -19,8 +19,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
integer_part(FloatType x) {
|
integer_part(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? -std::numeric_limits<FloatType>::infinity()
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == 0 ? x
|
: x == 0 ? x
|
||||||
: sprout::math::trunc(x)
|
: sprout::math::trunc(x)
|
||||||
;
|
;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef SPROUT_MATH_IROUND_HPP
|
#ifndef SPROUT_MATH_IROUND_HPP
|
||||||
#define SPROUT_MATH_IROUND_HPP
|
#define SPROUT_MATH_IROUND_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
#include <sprout/math/isinf.hpp>
|
#include <sprout/math/isinf.hpp>
|
||||||
|
@ -22,7 +22,7 @@ namespace sprout {
|
||||||
template<typename To, typename FloatType>
|
template<typename To, typename FloatType>
|
||||||
inline SPROUT_CONSTEXPR To
|
inline SPROUT_CONSTEXPR To
|
||||||
iround_impl(FloatType x) {
|
iround_impl(FloatType x) {
|
||||||
return std::numeric_limits<To>::max() < x || std::numeric_limits<To>::min() > x
|
return sprout::numeric_limits<To>::max() < x || sprout::numeric_limits<To>::min() > x
|
||||||
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("iround: large float rounding."), static_cast<To>(x))
|
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("iround: large float rounding."), static_cast<To>(x))
|
||||||
: static_cast<To>(x)
|
: static_cast<To>(x)
|
||||||
;
|
;
|
||||||
|
@ -34,7 +34,7 @@ namespace sprout {
|
||||||
>
|
>
|
||||||
inline SPROUT_CONSTEXPR To
|
inline SPROUT_CONSTEXPR To
|
||||||
iround(FloatType x) {
|
iround(FloatType x) {
|
||||||
return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits<To>::min()
|
return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits<To>::min()
|
||||||
: sprout::math::detail::iround_impl<To>(sprout::math::round(x))
|
: sprout::math::detail::iround_impl<To>(sprout::math::round(x))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -60,9 +60,9 @@ namespace sprout {
|
||||||
>
|
>
|
||||||
inline SPROUT_CONSTEXPR To
|
inline SPROUT_CONSTEXPR To
|
||||||
iround(FloatType x) {
|
iround(FloatType x) {
|
||||||
return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits<To>::min()
|
return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits<To>::min()
|
||||||
: x == 0 ? To(0)
|
: x == 0 ? To(0)
|
||||||
: std::numeric_limits<To>::max() < x || std::numeric_limits<To>::min() > x
|
: sprout::numeric_limits<To>::max() < x || sprout::numeric_limits<To>::min() > x
|
||||||
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("iround: large float irounding."), x)
|
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("iround: large float irounding."), x)
|
||||||
: x < 0 ? sprout::math::detail::iround_impl_nagative(x, static_cast<To>(x))
|
: x < 0 ? sprout::math::detail::iround_impl_nagative(x, static_cast<To>(x))
|
||||||
: sprout::math::detail::iround_impl_positive(x, static_cast<To>(x))
|
: sprout::math::detail::iround_impl_positive(x, static_cast<To>(x))
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_ISINF_HPP
|
#ifndef SPROUT_MATH_ISINF_HPP
|
||||||
#define SPROUT_MATH_ISINF_HPP
|
#define SPROUT_MATH_ISINF_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/type_traits/enabler_if.hpp>
|
#include <sprout/type_traits/enabler_if.hpp>
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ namespace sprout {
|
||||||
>
|
>
|
||||||
inline SPROUT_CONSTEXPR bool
|
inline SPROUT_CONSTEXPR bool
|
||||||
isinf(FloatType x) {
|
isinf(FloatType x) {
|
||||||
return x == std::numeric_limits<FloatType>::infinity()
|
return x == sprout::numeric_limits<FloatType>::infinity()
|
||||||
|| x == -std::numeric_limits<FloatType>::infinity()
|
|| x == -sprout::numeric_limits<FloatType>::infinity()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_ISSUBNORMAL_HPP
|
#ifndef SPROUT_MATH_ISSUBNORMAL_HPP
|
||||||
#define SPROUT_MATH_ISSUBNORMAL_HPP
|
#define SPROUT_MATH_ISSUBNORMAL_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/type_traits/enabler_if.hpp>
|
#include <sprout/type_traits/enabler_if.hpp>
|
||||||
#include <sprout/math/iszero.hpp>
|
#include <sprout/math/iszero.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -18,8 +18,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR bool
|
inline SPROUT_CONSTEXPR bool
|
||||||
issubnormal_or_zero(FloatType x) {
|
issubnormal_or_zero(FloatType x) {
|
||||||
return x > 0
|
return x > 0
|
||||||
? x < std::numeric_limits<double>::min()
|
? x < sprout::numeric_limits<double>::min()
|
||||||
: x > -std::numeric_limits<double>::min()
|
: x > -sprout::numeric_limits<double>::min()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef SPROUT_MATH_ITRUNC_HPP
|
#ifndef SPROUT_MATH_ITRUNC_HPP
|
||||||
#define SPROUT_MATH_ITRUNC_HPP
|
#define SPROUT_MATH_ITRUNC_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
#include <sprout/math/isinf.hpp>
|
#include <sprout/math/isinf.hpp>
|
||||||
|
@ -20,7 +20,7 @@ namespace sprout {
|
||||||
template<typename To, typename FloatType>
|
template<typename To, typename FloatType>
|
||||||
inline SPROUT_CONSTEXPR To
|
inline SPROUT_CONSTEXPR To
|
||||||
itrunc_impl(FloatType x) {
|
itrunc_impl(FloatType x) {
|
||||||
return std::numeric_limits<To>::max() < x || std::numeric_limits<To>::min() > x
|
return sprout::numeric_limits<To>::max() < x || sprout::numeric_limits<To>::min() > x
|
||||||
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("itrunc: large float rounding."), static_cast<To>(x))
|
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("itrunc: large float rounding."), static_cast<To>(x))
|
||||||
: static_cast<To>(x)
|
: static_cast<To>(x)
|
||||||
;
|
;
|
||||||
|
@ -32,7 +32,7 @@ namespace sprout {
|
||||||
>
|
>
|
||||||
inline SPROUT_CONSTEXPR To
|
inline SPROUT_CONSTEXPR To
|
||||||
itrunc(FloatType x) {
|
itrunc(FloatType x) {
|
||||||
return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits<To>::min()
|
return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits<To>::min()
|
||||||
: sprout::math::detail::itrunc_impl<To>(sprout::math::trunc(x))
|
: sprout::math::detail::itrunc_impl<To>(sprout::math::trunc(x))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -44,9 +44,9 @@ namespace sprout {
|
||||||
>
|
>
|
||||||
inline SPROUT_CONSTEXPR To
|
inline SPROUT_CONSTEXPR To
|
||||||
itrunc(FloatType x) {
|
itrunc(FloatType x) {
|
||||||
return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits<To>::min()
|
return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits<To>::min()
|
||||||
: x == 0 ? To(0)
|
: x == 0 ? To(0)
|
||||||
: std::numeric_limits<To>::max() < x || std::numeric_limits<To>::min() > x
|
: sprout::numeric_limits<To>::max() < x || sprout::numeric_limits<To>::min() > x
|
||||||
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("itrunc: large float rounding."), static_cast<To>(x))
|
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("itrunc: large float rounding."), static_cast<To>(x))
|
||||||
: static_cast<To>(x)
|
: static_cast<To>(x)
|
||||||
;
|
;
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#define SPROUT_MATH_LCM_HPP
|
#define SPROUT_MATH_LCM_HPP
|
||||||
|
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <limits>
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/gcd.hpp>
|
#include <sprout/math/gcd.hpp>
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
|
@ -56,7 +56,7 @@ namespace sprout {
|
||||||
struct lcm_optimal_evaluator {
|
struct lcm_optimal_evaluator {
|
||||||
public:
|
public:
|
||||||
SPROUT_CONSTEXPR T operator()(T const& a, T const& b) const {
|
SPROUT_CONSTEXPR T operator()(T const& a, T const& b) const {
|
||||||
typedef std::numeric_limits<T> limits_type;
|
typedef sprout::numeric_limits<T> limits_type;
|
||||||
typedef sprout::math::detail::lcm_optimal_evaluator_helper_t<
|
typedef sprout::math::detail::lcm_optimal_evaluator_helper_t<
|
||||||
T, limits_type::is_specialized, limits_type::is_signed
|
T, limits_type::is_specialized, limits_type::is_signed
|
||||||
> helper_type;
|
> helper_type;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_LDEXP_HPP
|
#ifndef SPROUT_MATH_LDEXP_HPP
|
||||||
#define SPROUT_MATH_LDEXP_HPP
|
#define SPROUT_MATH_LDEXP_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/detail/pow.hpp>
|
#include <sprout/detail/pow.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
|
@ -26,8 +26,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
ldexp(FloatType x, int exp) {
|
ldexp(FloatType x, int exp) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? -std::numeric_limits<FloatType>::infinity()
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
: exp == 0 ? x
|
: exp == 0 ? x
|
||||||
: x == 0 ? x
|
: x == 0 ? x
|
||||||
: static_cast<FloatType>(sprout::math::detail::ldexp_impl(static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x), exp))
|
: static_cast<FloatType>(sprout::math::detail::ldexp_impl(static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x), exp))
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_LGAMMA_HPP
|
#ifndef SPROUT_MATH_LGAMMA_HPP
|
||||||
#define SPROUT_MATH_LGAMMA_HPP
|
#define SPROUT_MATH_LGAMMA_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/constants.hpp>
|
#include <sprout/math/constants.hpp>
|
||||||
|
@ -184,9 +184,9 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
lgamma(FloatType x) {
|
lgamma(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x <= 0 && sprout::math::is_integer(x) ? std::numeric_limits<FloatType>::infinity()
|
: x <= 0 && sprout::math::is_integer(x) ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
//#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
//#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
// : std::lgamma(x)
|
// : std::lgamma(x)
|
||||||
//#else
|
//#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_LLROUND_HPP
|
#ifndef SPROUT_MATH_LLROUND_HPP
|
||||||
#define SPROUT_MATH_LLROUND_HPP
|
#define SPROUT_MATH_LLROUND_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
#include <sprout/math/isinf.hpp>
|
#include <sprout/math/isinf.hpp>
|
||||||
|
@ -19,7 +19,7 @@ namespace sprout {
|
||||||
>
|
>
|
||||||
inline SPROUT_CONSTEXPR long long
|
inline SPROUT_CONSTEXPR long long
|
||||||
llround(FloatType x) {
|
llround(FloatType x) {
|
||||||
return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits<long long>::min()
|
return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits<long long>::min()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::llround(x)
|
: std::llround(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#define SPROUT_MATH_LOG_HPP
|
#define SPROUT_MATH_LOG_HPP
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/detail/pow.hpp>
|
#include <sprout/detail/pow.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
|
@ -49,9 +49,9 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
log(FloatType x) {
|
log(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == 0 ? -std::numeric_limits<FloatType>::infinity()
|
: x == 0 ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x < 0 ? std::numeric_limits<FloatType>::quiet_NaN()
|
: x < 0 ? sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::log(x)
|
: std::log(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_LOG10_HPP
|
#ifndef SPROUT_MATH_LOG10_HPP
|
||||||
#define SPROUT_MATH_LOG10_HPP
|
#define SPROUT_MATH_LOG10_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/constants.hpp>
|
#include <sprout/math/constants.hpp>
|
||||||
|
@ -27,9 +27,9 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
log10(FloatType x) {
|
log10(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == 0 ? -std::numeric_limits<FloatType>::infinity()
|
: x == 0 ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x < 0 ? std::numeric_limits<FloatType>::quiet_NaN()
|
: x < 0 ? sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::log10(x)
|
: std::log10(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_LOG1P_HPP
|
#ifndef SPROUT_MATH_LOG1P_HPP
|
||||||
#define SPROUT_MATH_LOG1P_HPP
|
#define SPROUT_MATH_LOG1P_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -26,9 +26,9 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
log1p(FloatType x) {
|
log1p(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == -1 ? -std::numeric_limits<FloatType>::infinity()
|
: x == -1 ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x < -1 ? -std::numeric_limits<FloatType>::quiet_NaN()
|
: x < -1 ? -sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::log1p(x)
|
: std::log1p(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_LOG2_HPP
|
#ifndef SPROUT_MATH_LOG2_HPP
|
||||||
#define SPROUT_MATH_LOG2_HPP
|
#define SPROUT_MATH_LOG2_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/constants.hpp>
|
#include <sprout/math/constants.hpp>
|
||||||
|
@ -27,9 +27,9 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
log2(FloatType x) {
|
log2(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == 0 ? -std::numeric_limits<FloatType>::infinity()
|
: x == 0 ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x < 0 ? std::numeric_limits<FloatType>::quiet_NaN()
|
: x < 0 ? sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::log2(x)
|
: std::log2(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#define SPROUT_MATH_LOGB_HPP
|
#define SPROUT_MATH_LOGB_HPP
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/detail/pow.hpp>
|
#include <sprout/detail/pow.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
|
@ -22,7 +22,7 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR T
|
inline SPROUT_CONSTEXPR T
|
||||||
logb_impl_3_neg_lo(T x, T x0, T base, T exp) {
|
logb_impl_3_neg_lo(T x, T x0, T base, T exp) {
|
||||||
return base < 1 ? sprout::math::detail::logb_impl_3_neg_lo(
|
return base < 1 ? sprout::math::detail::logb_impl_3_neg_lo(
|
||||||
x, x0 * std::numeric_limits<T>::radix, x / (x0 / std::numeric_limits<T>::radix), exp - 1
|
x, x0 * sprout::numeric_limits<T>::radix, x / (x0 / sprout::numeric_limits<T>::radix), exp - 1
|
||||||
)
|
)
|
||||||
: exp
|
: exp
|
||||||
;
|
;
|
||||||
|
@ -30,8 +30,8 @@ namespace sprout {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline SPROUT_CONSTEXPR T
|
inline SPROUT_CONSTEXPR T
|
||||||
logb_impl_3_neg_hi(T x, T x0, T base, T exp) {
|
logb_impl_3_neg_hi(T x, T x0, T base, T exp) {
|
||||||
return !(base < std::numeric_limits<T>::radix) ? sprout::math::detail::logb_impl_3_neg_hi(
|
return !(base < sprout::numeric_limits<T>::radix) ? sprout::math::detail::logb_impl_3_neg_hi(
|
||||||
x, x0 / std::numeric_limits<T>::radix, x / (x0 * std::numeric_limits<T>::radix), exp + 1
|
x, x0 / sprout::numeric_limits<T>::radix, x / (x0 * sprout::numeric_limits<T>::radix), exp + 1
|
||||||
)
|
)
|
||||||
: exp
|
: exp
|
||||||
;
|
;
|
||||||
|
@ -40,7 +40,7 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR T
|
inline SPROUT_CONSTEXPR T
|
||||||
logb_impl_3_pos_lo(T x, T x0, T base, T exp) {
|
logb_impl_3_pos_lo(T x, T x0, T base, T exp) {
|
||||||
return base < 1 ? sprout::math::detail::logb_impl_3_pos_lo(
|
return base < 1 ? sprout::math::detail::logb_impl_3_pos_lo(
|
||||||
x, x0 * std::numeric_limits<T>::radix, x / (x0 / std::numeric_limits<T>::radix), exp - 1
|
x, x0 * sprout::numeric_limits<T>::radix, x / (x0 / sprout::numeric_limits<T>::radix), exp - 1
|
||||||
)
|
)
|
||||||
: exp
|
: exp
|
||||||
;
|
;
|
||||||
|
@ -48,8 +48,8 @@ namespace sprout {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline SPROUT_CONSTEXPR T
|
inline SPROUT_CONSTEXPR T
|
||||||
logb_impl_3_pos_hi(T x, T x0, T base, T exp) {
|
logb_impl_3_pos_hi(T x, T x0, T base, T exp) {
|
||||||
return !(base < std::numeric_limits<T>::radix) ? sprout::math::detail::logb_impl_3_pos_hi(
|
return !(base < sprout::numeric_limits<T>::radix) ? sprout::math::detail::logb_impl_3_pos_hi(
|
||||||
x, x0 / std::numeric_limits<T>::radix, x / (x0 * std::numeric_limits<T>::radix), exp + 1
|
x, x0 / sprout::numeric_limits<T>::radix, x / (x0 * sprout::numeric_limits<T>::radix), exp + 1
|
||||||
)
|
)
|
||||||
: exp
|
: exp
|
||||||
;
|
;
|
||||||
|
@ -59,17 +59,17 @@ namespace sprout {
|
||||||
logb_impl_3(T x, T x0, T base, T exp) {
|
logb_impl_3(T x, T x0, T base, T exp) {
|
||||||
return x < 1
|
return x < 1
|
||||||
? base < 1 ? sprout::math::detail::logb_impl_3_neg_lo(
|
? base < 1 ? sprout::math::detail::logb_impl_3_neg_lo(
|
||||||
x, x0 * std::numeric_limits<T>::radix, x / (x0 / std::numeric_limits<T>::radix), exp - 1
|
x, x0 * sprout::numeric_limits<T>::radix, x / (x0 / sprout::numeric_limits<T>::radix), exp - 1
|
||||||
)
|
)
|
||||||
: !(base < std::numeric_limits<T>::radix) ? sprout::math::detail::logb_impl_3_neg_hi(
|
: !(base < sprout::numeric_limits<T>::radix) ? sprout::math::detail::logb_impl_3_neg_hi(
|
||||||
x, x0 / std::numeric_limits<T>::radix, x / (x0 * std::numeric_limits<T>::radix), exp + 1
|
x, x0 / sprout::numeric_limits<T>::radix, x / (x0 * sprout::numeric_limits<T>::radix), exp + 1
|
||||||
)
|
)
|
||||||
: exp
|
: exp
|
||||||
: base < 1 ? sprout::math::detail::logb_impl_3_pos_lo(
|
: base < 1 ? sprout::math::detail::logb_impl_3_pos_lo(
|
||||||
x, x0 * std::numeric_limits<T>::radix, x / (x0 / std::numeric_limits<T>::radix), exp - 1
|
x, x0 * sprout::numeric_limits<T>::radix, x / (x0 / sprout::numeric_limits<T>::radix), exp - 1
|
||||||
)
|
)
|
||||||
: !(base < std::numeric_limits<T>::radix) ? sprout::math::detail::logb_impl_3_pos_hi(
|
: !(base < sprout::numeric_limits<T>::radix) ? sprout::math::detail::logb_impl_3_pos_hi(
|
||||||
x, x0 / std::numeric_limits<T>::radix, x / (x0 * std::numeric_limits<T>::radix), exp + 1
|
x, x0 / sprout::numeric_limits<T>::radix, x / (x0 * sprout::numeric_limits<T>::radix), exp + 1
|
||||||
)
|
)
|
||||||
: exp
|
: exp
|
||||||
;
|
;
|
||||||
|
@ -83,14 +83,14 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR T
|
inline SPROUT_CONSTEXPR T
|
||||||
logb_impl_1(T x, T exp) {
|
logb_impl_1(T x, T exp) {
|
||||||
return sprout::math::detail::logb_impl_2(
|
return sprout::math::detail::logb_impl_2(
|
||||||
x, sprout::detail::pow_n(T(std::numeric_limits<T>::radix), sprout::math::itrunc<std::intmax_t>(exp)), exp
|
x, sprout::detail::pow_n(T(sprout::numeric_limits<T>::radix), sprout::math::itrunc<std::intmax_t>(exp)), exp
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline SPROUT_CONSTEXPR T
|
inline SPROUT_CONSTEXPR T
|
||||||
logb_impl(T x) {
|
logb_impl(T x) {
|
||||||
return x < 0 ? sprout::math::detail::logb_impl_1(-x, sprout::math::trunc(sprout::math::log_a(T(std::numeric_limits<T>::radix), -x)))
|
return x < 0 ? sprout::math::detail::logb_impl_1(-x, sprout::math::trunc(sprout::math::log_a(T(sprout::numeric_limits<T>::radix), -x)))
|
||||||
: sprout::math::detail::logb_impl_1(x, sprout::math::trunc(sprout::math::log_a(T(std::numeric_limits<T>::radix), x)))
|
: sprout::math::detail::logb_impl_1(x, sprout::math::trunc(sprout::math::log_a(T(sprout::numeric_limits<T>::radix), x)))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,16 +101,16 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
logb(FloatType x) {
|
logb(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == 0 ? -std::numeric_limits<FloatType>::infinity()
|
: x == 0 ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
# if defined(__GNUC__)
|
# if defined(__GNUC__)
|
||||||
: x == -std::numeric_limits<FloatType>::infinity()
|
: x == -sprout::numeric_limits<FloatType>::infinity()
|
||||||
? std::numeric_limits<FloatType>::infinity()
|
? sprout::numeric_limits<FloatType>::infinity()
|
||||||
# endif
|
# endif
|
||||||
: std::logb(x)
|
: std::logb(x)
|
||||||
#else
|
#else
|
||||||
: x == std::numeric_limits<FloatType>::infinity() || x == -std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() || x == -sprout::numeric_limits<FloatType>::infinity()
|
||||||
? std::numeric_limits<FloatType>::infinity()
|
? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: static_cast<FloatType>(sprout::math::detail::logb_impl(static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x)))
|
: static_cast<FloatType>(sprout::math::detail::logb_impl(static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x)))
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
# include <sprout/math/logb.hpp>
|
# include <sprout/math/logb.hpp>
|
||||||
#else
|
#else
|
||||||
# include <cstdint>
|
# include <cstdint>
|
||||||
# include <limits>
|
# include <sprout/limits.hpp>
|
||||||
# include <sprout/detail/pow.hpp>
|
# include <sprout/detail/pow.hpp>
|
||||||
# include <sprout/math/detail/float_compute.hpp>
|
# include <sprout/math/detail/float_compute.hpp>
|
||||||
# include <sprout/math/isnan.hpp>
|
# include <sprout/math/isnan.hpp>
|
||||||
|
@ -123,9 +123,9 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
logb2(FloatType x) {
|
logb2(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == 0 ? -std::numeric_limits<FloatType>::infinity()
|
: x == 0 ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == std::numeric_limits<FloatType>::infinity() || x == -std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() || x == -sprout::numeric_limits<FloatType>::infinity()
|
||||||
? std::numeric_limits<FloatType>::infinity()
|
? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: static_cast<FloatType>(sprout::math::detail::logb2_impl(static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x)))
|
: static_cast<FloatType>(sprout::math::detail::logb2_impl(static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x)))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_LROUND_HPP
|
#ifndef SPROUT_MATH_LROUND_HPP
|
||||||
#define SPROUT_MATH_LROUND_HPP
|
#define SPROUT_MATH_LROUND_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
#include <sprout/math/isinf.hpp>
|
#include <sprout/math/isinf.hpp>
|
||||||
|
@ -19,7 +19,7 @@ namespace sprout {
|
||||||
>
|
>
|
||||||
inline SPROUT_CONSTEXPR long
|
inline SPROUT_CONSTEXPR long
|
||||||
lround(FloatType x) {
|
lround(FloatType x) {
|
||||||
return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits<long>::min()
|
return sprout::math::isnan(x) || sprout::math::isinf(x) ? sprout::numeric_limits<long>::min()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::lround(x)
|
: std::lround(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_POW_HPP
|
#ifndef SPROUT_MATH_POW_HPP
|
||||||
#define SPROUT_MATH_POW_HPP
|
#define SPROUT_MATH_POW_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/constants.hpp>
|
#include <sprout/math/constants.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -37,27 +37,27 @@ namespace sprout {
|
||||||
: sprout::math::isnan(x) ? x
|
: sprout::math::isnan(x) ? x
|
||||||
: x == 0
|
: x == 0
|
||||||
? y < 0
|
? y < 0
|
||||||
? sprout::math::is_odd(y) ? sprout::math::copysign(std::numeric_limits<FloatType>::infinity(), x)
|
? sprout::math::is_odd(y) ? sprout::math::copysign(sprout::numeric_limits<FloatType>::infinity(), x)
|
||||||
: std::numeric_limits<FloatType>::infinity()
|
: sprout::numeric_limits<FloatType>::infinity()
|
||||||
: sprout::math::is_odd(y) ? x
|
: sprout::math::is_odd(y) ? x
|
||||||
: FloatType(0)
|
: FloatType(0)
|
||||||
: x == -1 && (y == std::numeric_limits<FloatType>::infinity() || y == -std::numeric_limits<FloatType>::infinity()) ? FloatType(1)
|
: x == -1 && (y == sprout::numeric_limits<FloatType>::infinity() || y == -sprout::numeric_limits<FloatType>::infinity()) ? FloatType(1)
|
||||||
: y == -std::numeric_limits<FloatType>::infinity()
|
: y == -sprout::numeric_limits<FloatType>::infinity()
|
||||||
? sprout::math::fabs(x) < 1 ? std::numeric_limits<FloatType>::infinity()
|
? sprout::math::fabs(x) < 1 ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: FloatType(0)
|
: FloatType(0)
|
||||||
: y == std::numeric_limits<FloatType>::infinity()
|
: y == sprout::numeric_limits<FloatType>::infinity()
|
||||||
? sprout::math::fabs(x) < 1 ? FloatType(0)
|
? sprout::math::fabs(x) < 1 ? FloatType(0)
|
||||||
: std::numeric_limits<FloatType>::infinity()
|
: sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == -std::numeric_limits<FloatType>::infinity()
|
: x == -sprout::numeric_limits<FloatType>::infinity()
|
||||||
? y < 0
|
? y < 0
|
||||||
? sprout::math::is_odd(y) ? -FloatType(0)
|
? sprout::math::is_odd(y) ? -FloatType(0)
|
||||||
: FloatType(0)
|
: FloatType(0)
|
||||||
: sprout::math::is_odd(y) ? -std::numeric_limits<FloatType>::infinity()
|
: sprout::math::is_odd(y) ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
: std::numeric_limits<FloatType>::infinity()
|
: sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity()
|
||||||
? y < 0 ? FloatType(0)
|
? y < 0 ? FloatType(0)
|
||||||
: std::numeric_limits<FloatType>::infinity()
|
: sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x < 0 && !sprout::math::is_integer(y) ? std::numeric_limits<FloatType>::quiet_NaN()
|
: x < 0 && !sprout::math::is_integer(y) ? sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::pow(x, y)
|
: std::pow(x, y)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_QUOTIENT_HPP
|
#ifndef SPROUT_MATH_QUOTIENT_HPP
|
||||||
#define SPROUT_MATH_QUOTIENT_HPP
|
#define SPROUT_MATH_QUOTIENT_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
#include <sprout/math/signbit.hpp>
|
#include <sprout/math/signbit.hpp>
|
||||||
|
@ -23,10 +23,10 @@ namespace sprout {
|
||||||
quotient(FloatType x, FloatType y) {
|
quotient(FloatType x, FloatType y) {
|
||||||
return y == 0 ? R(0)
|
return y == 0 ? R(0)
|
||||||
: sprout::math::isnan(y) || sprout::math::isnan(x) ? R(0)
|
: sprout::math::isnan(y) || sprout::math::isnan(x) ? R(0)
|
||||||
: x == std::numeric_limits<FloatType>::infinity() || x == -std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() || x == -sprout::numeric_limits<FloatType>::infinity()
|
||||||
? R(0)
|
? R(0)
|
||||||
: x == 0 ? R(0)
|
: x == 0 ? R(0)
|
||||||
: y == std::numeric_limits<FloatType>::infinity() || y == -std::numeric_limits<FloatType>::infinity() ? R(0)
|
: y == sprout::numeric_limits<FloatType>::infinity() || y == -sprout::numeric_limits<FloatType>::infinity() ? R(0)
|
||||||
: sprout::math::rem_quo<R>(x, y).second
|
: sprout::math::rem_quo<R>(x, y).second
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_REM_QUO_HPP
|
#ifndef SPROUT_MATH_REM_QUO_HPP
|
||||||
#define SPROUT_MATH_REM_QUO_HPP
|
#define SPROUT_MATH_REM_QUO_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -89,16 +89,16 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR sprout::pair<FloatType, R>
|
inline SPROUT_CONSTEXPR sprout::pair<FloatType, R>
|
||||||
rem_quo(FloatType x, FloatType y) {
|
rem_quo(FloatType x, FloatType y) {
|
||||||
typedef sprout::pair<FloatType, R> type;
|
typedef sprout::pair<FloatType, R> type;
|
||||||
return y == 0 ? type(-std::numeric_limits<FloatType>::quiet_NaN(), R(0))
|
return y == 0 ? type(-sprout::numeric_limits<FloatType>::quiet_NaN(), R(0))
|
||||||
: sprout::math::isnan(y)
|
: sprout::math::isnan(y)
|
||||||
? sprout::math::isnan(x)
|
? sprout::math::isnan(x)
|
||||||
? type(sprout::math::signbit(y) && sprout::math::signbit(x) ? -std::numeric_limits<FloatType>::quiet_NaN() : std::numeric_limits<FloatType>::quiet_NaN(), R(0))
|
? type(sprout::math::signbit(y) && sprout::math::signbit(x) ? -sprout::numeric_limits<FloatType>::quiet_NaN() : sprout::numeric_limits<FloatType>::quiet_NaN(), R(0))
|
||||||
: type(y, R(0))
|
: type(y, R(0))
|
||||||
: sprout::math::isnan(x) ? type(x, R(0))
|
: sprout::math::isnan(x) ? type(x, R(0))
|
||||||
: x == std::numeric_limits<FloatType>::infinity() || x == -std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() || x == -sprout::numeric_limits<FloatType>::infinity()
|
||||||
? type(-std::numeric_limits<FloatType>::quiet_NaN(), R(0))
|
? type(-sprout::numeric_limits<FloatType>::quiet_NaN(), R(0))
|
||||||
: x == 0 ? type(x, R(0))
|
: x == 0 ? type(x, R(0))
|
||||||
: y == std::numeric_limits<FloatType>::infinity() || y == -std::numeric_limits<FloatType>::infinity() ? type(x, R(0))
|
: y == sprout::numeric_limits<FloatType>::infinity() || y == -sprout::numeric_limits<FloatType>::infinity() ? type(x, R(0))
|
||||||
: sprout::math::detail::rem_quo_ret<R, FloatType>(sprout::math::detail::rem_quo_impl(
|
: sprout::math::detail::rem_quo_ret<R, FloatType>(sprout::math::detail::rem_quo_impl(
|
||||||
static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x),
|
static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x),
|
||||||
static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(y),
|
static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(y),
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_REMAINDER_HPP
|
#ifndef SPROUT_MATH_REMAINDER_HPP
|
||||||
#define SPROUT_MATH_REMAINDER_HPP
|
#define SPROUT_MATH_REMAINDER_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
#include <sprout/math/signbit.hpp>
|
#include <sprout/math/signbit.hpp>
|
||||||
|
@ -20,17 +20,17 @@ namespace sprout {
|
||||||
>
|
>
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
remainder(FloatType x, FloatType y) {
|
remainder(FloatType x, FloatType y) {
|
||||||
return y == 0 ? -std::numeric_limits<FloatType>::quiet_NaN()
|
return y == 0 ? -sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
: sprout::math::isnan(y)
|
: sprout::math::isnan(y)
|
||||||
? sprout::math::isnan(x)
|
? sprout::math::isnan(x)
|
||||||
? sprout::math::signbit(y) && sprout::math::signbit(x) ? -std::numeric_limits<FloatType>::quiet_NaN()
|
? sprout::math::signbit(y) && sprout::math::signbit(x) ? -sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
: std::numeric_limits<FloatType>::quiet_NaN()
|
: sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
: y
|
: y
|
||||||
: sprout::math::isnan(x) ? x
|
: sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() || x == -std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() || x == -sprout::numeric_limits<FloatType>::infinity()
|
||||||
? -std::numeric_limits<FloatType>::quiet_NaN()
|
? -sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
: x == 0 ? x
|
: x == 0 ? x
|
||||||
: y == std::numeric_limits<FloatType>::infinity() || y == -std::numeric_limits<FloatType>::infinity() ? x
|
: y == sprout::numeric_limits<FloatType>::infinity() || y == -sprout::numeric_limits<FloatType>::infinity() ? x
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::remainder(x, y)
|
: std::remainder(x, y)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
#define SPROUT_MATH_ROUND_HPP
|
#define SPROUT_MATH_ROUND_HPP
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -43,13 +43,13 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
round(FloatType x) {
|
round(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? -std::numeric_limits<FloatType>::infinity()
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::round(x)
|
: std::round(x)
|
||||||
#else
|
#else
|
||||||
: x == 0 ? x
|
: x == 0 ? x
|
||||||
: std::numeric_limits<std::uintmax_t>::max() < x || std::numeric_limits<std::uintmax_t>::max() < -x
|
: sprout::numeric_limits<std::uintmax_t>::max() < x || sprout::numeric_limits<std::uintmax_t>::max() < -x
|
||||||
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("round: large float rounding."), x)
|
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("round: large float rounding."), x)
|
||||||
: static_cast<FloatType>(sprout::math::detail::round_impl(static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x)))
|
: static_cast<FloatType>(sprout::math::detail::round_impl(static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x)))
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_SCALBLN_HPP
|
#ifndef SPROUT_MATH_SCALBLN_HPP
|
||||||
#define SPROUT_MATH_SCALBLN_HPP
|
#define SPROUT_MATH_SCALBLN_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/detail/pow.hpp>
|
#include <sprout/detail/pow.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
|
@ -16,7 +16,7 @@ namespace sprout {
|
||||||
template<typename FloatType, typename T>
|
template<typename FloatType, typename T>
|
||||||
inline SPROUT_CONSTEXPR T
|
inline SPROUT_CONSTEXPR T
|
||||||
scalbln_impl(T x, long exp) {
|
scalbln_impl(T x, long exp) {
|
||||||
return x * sprout::detail::pow_n(T(std::numeric_limits<FloatType>::radix), exp);
|
return x * sprout::detail::pow_n(T(sprout::numeric_limits<FloatType>::radix), exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<
|
template<
|
||||||
|
@ -26,8 +26,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
scalbln(FloatType x, long exp) {
|
scalbln(FloatType x, long exp) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? -std::numeric_limits<FloatType>::infinity()
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
: exp == 0 ? x
|
: exp == 0 ? x
|
||||||
: x == 0 ? x
|
: x == 0 ? x
|
||||||
: static_cast<FloatType>(sprout::math::detail::scalbln_impl<FloatType>(static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x), exp))
|
: static_cast<FloatType>(sprout::math::detail::scalbln_impl<FloatType>(static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x), exp))
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_SCALBN_HPP
|
#ifndef SPROUT_MATH_SCALBN_HPP
|
||||||
#define SPROUT_MATH_SCALBN_HPP
|
#define SPROUT_MATH_SCALBN_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/detail/pow.hpp>
|
#include <sprout/detail/pow.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
|
@ -16,7 +16,7 @@ namespace sprout {
|
||||||
template<typename FloatType, typename T>
|
template<typename FloatType, typename T>
|
||||||
inline SPROUT_CONSTEXPR T
|
inline SPROUT_CONSTEXPR T
|
||||||
scalbn_impl(T x, int exp) {
|
scalbn_impl(T x, int exp) {
|
||||||
return x * sprout::detail::pow_n(T(std::numeric_limits<FloatType>::radix), exp);
|
return x * sprout::detail::pow_n(T(sprout::numeric_limits<FloatType>::radix), exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<
|
template<
|
||||||
|
@ -26,8 +26,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
scalbn(FloatType x, int exp) {
|
scalbn(FloatType x, int exp) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? -std::numeric_limits<FloatType>::infinity()
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
: exp == 0 ? x
|
: exp == 0 ? x
|
||||||
: x == 0 ? x
|
: x == 0 ? x
|
||||||
: static_cast<FloatType>(sprout::math::detail::scalbn_impl<FloatType>(static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x), exp))
|
: static_cast<FloatType>(sprout::math::detail::scalbn_impl<FloatType>(static_cast<typename sprout::math::detail::float_compute<FloatType>::type>(x), exp))
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_SIN_HPP
|
#ifndef SPROUT_MATH_SIN_HPP
|
||||||
#define SPROUT_MATH_SIN_HPP
|
#define SPROUT_MATH_SIN_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/constants.hpp>
|
#include <sprout/math/constants.hpp>
|
||||||
|
@ -27,8 +27,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
sin(FloatType x) {
|
sin(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() || x == -std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() || x == -sprout::numeric_limits<FloatType>::infinity()
|
||||||
? -std::numeric_limits<FloatType>::quiet_NaN()
|
? -sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::sin(x)
|
: std::sin(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#define SPROUT_MATH_SINH_HPP
|
#define SPROUT_MATH_SINH_HPP
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -32,8 +32,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
sinh(FloatType x) {
|
sinh(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? -std::numeric_limits<FloatType>::infinity()
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::sinh(x)
|
: std::sinh(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_SQRT_HPP
|
#ifndef SPROUT_MATH_SQRT_HPP
|
||||||
#define SPROUT_MATH_SQRT_HPP
|
#define SPROUT_MATH_SQRT_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -37,8 +37,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
sqrt(FloatType x) {
|
sqrt(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x < 0 ? -std::numeric_limits<FloatType>::quiet_NaN()
|
: x < 0 ? -sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::sqrt(x)
|
: std::sqrt(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_TAN_HPP
|
#ifndef SPROUT_MATH_TAN_HPP
|
||||||
#define SPROUT_MATH_TAN_HPP
|
#define SPROUT_MATH_TAN_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -27,8 +27,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
tan(FloatType x) {
|
tan(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() || x == -std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() || x == -sprout::numeric_limits<FloatType>::infinity()
|
||||||
? -std::numeric_limits<FloatType>::quiet_NaN()
|
? -sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::tan(x)
|
: std::tan(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_MATH_TANH_HPP
|
#ifndef SPROUT_MATH_TANH_HPP
|
||||||
#define SPROUT_MATH_TANH_HPP
|
#define SPROUT_MATH_TANH_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -36,8 +36,8 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
tanh(FloatType x) {
|
tanh(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? FloatType(1)
|
: x == sprout::numeric_limits<FloatType>::infinity() ? FloatType(1)
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? FloatType(-1)
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? FloatType(-1)
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::tanh(x)
|
: std::tanh(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#define SPROUT_MATH_TGAMMA_HPP
|
#define SPROUT_MATH_TGAMMA_HPP
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/detail/float_compute.hpp>
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
|
@ -71,7 +71,7 @@ namespace sprout {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline SPROUT_CONSTEXPR T
|
inline SPROUT_CONSTEXPR T
|
||||||
tgamma_impl_2_pos_rec(T x, T y, T t) {
|
tgamma_impl_2_pos_rec(T x, T y, T t) {
|
||||||
return t == 0 ? std::numeric_limits<T>::infinity()
|
return t == 0 ? sprout::numeric_limits<T>::infinity()
|
||||||
: (x - T(1)) / y / t
|
: (x - T(1)) / y / t
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -108,10 +108,10 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
tgamma(FloatType x) {
|
tgamma(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == 0 ? sprout::math::copysign(std::numeric_limits<FloatType>::infinity(), x)
|
: x == 0 ? sprout::math::copysign(sprout::numeric_limits<FloatType>::infinity(), x)
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? -std::numeric_limits<FloatType>::quiet_NaN()
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? -sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x < 0 && sprout::math::is_integer(x) ? std::numeric_limits<FloatType>::quiet_NaN()
|
: x < 0 && sprout::math::is_integer(x) ? sprout::numeric_limits<FloatType>::quiet_NaN()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::tgamma(x)
|
: std::tgamma(x)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
#define SPROUT_MATH_TRUNC_HPP
|
#define SPROUT_MATH_TRUNC_HPP
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/detail/config.hpp>
|
#include <sprout/math/detail/config.hpp>
|
||||||
#include <sprout/math/isnan.hpp>
|
#include <sprout/math/isnan.hpp>
|
||||||
#include <sprout/type_traits/enabler_if.hpp>
|
#include <sprout/type_traits/enabler_if.hpp>
|
||||||
|
@ -20,13 +20,13 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR FloatType
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
trunc(FloatType x) {
|
trunc(FloatType x) {
|
||||||
return sprout::math::isnan(x) ? x
|
return sprout::math::isnan(x) ? x
|
||||||
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
: x == sprout::numeric_limits<FloatType>::infinity() ? sprout::numeric_limits<FloatType>::infinity()
|
||||||
: x == -std::numeric_limits<FloatType>::infinity() ? -std::numeric_limits<FloatType>::infinity()
|
: x == -sprout::numeric_limits<FloatType>::infinity() ? -sprout::numeric_limits<FloatType>::infinity()
|
||||||
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
|
||||||
: std::trunc(x)
|
: std::trunc(x)
|
||||||
#else
|
#else
|
||||||
: x == 0 ? x
|
: x == 0 ? x
|
||||||
: std::numeric_limits<std::uintmax_t>::max() < x || std::numeric_limits<std::uintmax_t>::max() < -x
|
: sprout::numeric_limits<std::uintmax_t>::max() < x || sprout::numeric_limits<std::uintmax_t>::max() < -x
|
||||||
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("trunc: large float rounding."), x)
|
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("trunc: large float rounding."), x)
|
||||||
: x < 0 ? -static_cast<FloatType>(static_cast<std::uintmax_t>(-x))
|
: x < 0 ? -static_cast<FloatType>(static_cast<std::uintmax_t>(-x))
|
||||||
: static_cast<FloatType>(static_cast<std::uintmax_t>(x))
|
: static_cast<FloatType>(static_cast<std::uintmax_t>(x))
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef SPROUT_RANDOM_DETAIL_CONST_MOD_HPP
|
#ifndef SPROUT_RANDOM_DETAIL_CONST_MOD_HPP
|
||||||
#define SPROUT_RANDOM_DETAIL_CONST_MOD_HPP
|
#define SPROUT_RANDOM_DETAIL_CONST_MOD_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/assert.hpp>
|
#include <sprout/assert.hpp>
|
||||||
#ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE
|
#ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE
|
||||||
# include <sprout/workaround/recursive_function_template.hpp>
|
# include <sprout/workaround/recursive_function_template.hpp>
|
||||||
|
@ -41,7 +41,7 @@ namespace sprout {
|
||||||
return mult_schrage_1(a, value, m / a, m % a);
|
return mult_schrage_1(a, value, m / a, m % a);
|
||||||
}
|
}
|
||||||
static SPROUT_CONSTEXPR IntType mult_general(IntType a, IntType b) {
|
static SPROUT_CONSTEXPR IntType mult_general(IntType a, IntType b) {
|
||||||
return std::uintmax_t(modulus) <= std::numeric_limits<std::uintmax_t>::max() / modulus
|
return std::uintmax_t(modulus) <= sprout::numeric_limits<std::uintmax_t>::max() / modulus
|
||||||
? static_cast<IntType>(std::uintmax_t(a) * b % modulus)
|
? static_cast<IntType>(std::uintmax_t(a) * b % modulus)
|
||||||
//: static_cast<IntType>(sprout::random::detail::mulmod(a, b, modulus)) // ???
|
//: static_cast<IntType>(sprout::random::detail::mulmod(a, b, modulus)) // ???
|
||||||
: (SPROUT_ASSERT_MSG(0, "Sorry, not implemented."), IntType())
|
: (SPROUT_ASSERT_MSG(0, "Sorry, not implemented."), IntType())
|
||||||
|
@ -51,7 +51,7 @@ namespace sprout {
|
||||||
return a < b ? m - (b - a) : a - b;
|
return a < b ? m - (b - a) : a - b;
|
||||||
}
|
}
|
||||||
static SPROUT_CONSTEXPR unsigned_type unsigned_m() {
|
static SPROUT_CONSTEXPR unsigned_type unsigned_m() {
|
||||||
return m == 0 ? unsigned_type((std::numeric_limits<IntType>::max)()) + 1 : unsigned_type(m);
|
return m == 0 ? unsigned_type((sprout::numeric_limits<IntType>::max)()) + 1 : unsigned_type(m);
|
||||||
}
|
}
|
||||||
#ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE
|
#ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE
|
||||||
template<int D, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
template<int D, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||||
|
@ -106,10 +106,10 @@ namespace sprout {
|
||||||
}
|
}
|
||||||
template<int D, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
template<int D, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||||
static SPROUT_CONSTEXPR IntType invert_euclidian0_1(IntType c, IntType l1, IntType l2, IntType n) {
|
static SPROUT_CONSTEXPR IntType invert_euclidian0_1(IntType c, IntType l1, IntType l2, IntType n) {
|
||||||
return SPROUT_ASSERT_MSG(std::numeric_limits<IntType>::max() % n != n - 1, "c must be relatively prime to m."),
|
return SPROUT_ASSERT_MSG(sprout::numeric_limits<IntType>::max() % n != n - 1, "c must be relatively prime to m."),
|
||||||
invert_euclidian0_2<D + 1>(
|
invert_euclidian0_2<D + 1>(
|
||||||
c, l1 + (std::numeric_limits<IntType>::max() / n) * l2, l2, n,
|
c, l1 + (sprout::numeric_limits<IntType>::max() / n) * l2, l2, n,
|
||||||
std::numeric_limits<IntType>::max() - (std::numeric_limits<IntType>::max() / n) * n + 1
|
sprout::numeric_limits<IntType>::max() - (sprout::numeric_limits<IntType>::max() / n) * n + 1
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -149,10 +149,10 @@ namespace sprout {
|
||||||
return p == 0 ? l2 : invert_euclidian0_3(c, l1, l2 + (n / p) * l1, n - (n / p) * p, p);
|
return p == 0 ? l2 : invert_euclidian0_3(c, l1, l2 + (n / p) * l1, n - (n / p) * p, p);
|
||||||
}
|
}
|
||||||
static SPROUT_CONSTEXPR IntType invert_euclidian0_1(IntType c, IntType l1, IntType l2, IntType n) {
|
static SPROUT_CONSTEXPR IntType invert_euclidian0_1(IntType c, IntType l1, IntType l2, IntType n) {
|
||||||
return SPROUT_ASSERT_MSG(std::numeric_limits<IntType>::max() % n != n - 1, "c must be relatively prime to m."),
|
return SPROUT_ASSERT_MSG(sprout::numeric_limits<IntType>::max() % n != n - 1, "c must be relatively prime to m."),
|
||||||
invert_euclidian0_2(
|
invert_euclidian0_2(
|
||||||
c, l1 + (std::numeric_limits<IntType>::max() / n) * l2, l2, n,
|
c, l1 + (sprout::numeric_limits<IntType>::max() / n) * l2, l2, n,
|
||||||
std::numeric_limits<IntType>::max() - (std::numeric_limits<IntType>::max() / n) * n + 1
|
sprout::numeric_limits<IntType>::max() - (sprout::numeric_limits<IntType>::max() / n) * n + 1
|
||||||
)
|
)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -180,15 +180,15 @@ namespace sprout {
|
||||||
return ((unsigned_m() - 1) & unsigned_m()) == 0 ? unsigned_type(a) * unsigned_type(x) & (unsigned_m() - 1)
|
return ((unsigned_m() - 1) & unsigned_m()) == 0 ? unsigned_type(a) * unsigned_type(x) & (unsigned_m() - 1)
|
||||||
: a == 0 ? 0
|
: a == 0 ? 0
|
||||||
: a == 1 ? x
|
: a == 1 ? x
|
||||||
: m <= std::numeric_limits<IntType>::max() / a ? mult_small(a, x)
|
: m <= sprout::numeric_limits<IntType>::max() / a ? mult_small(a, x)
|
||||||
: std::numeric_limits<IntType>::is_signed && (m % a < m / a) ? mult_schrage(a, x)
|
: sprout::numeric_limits<IntType>::is_signed && (m % a < m / a) ? mult_schrage(a, x)
|
||||||
: mult_general(a, x)
|
: mult_general(a, x)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
static SPROUT_CONSTEXPR IntType mult_add(IntType a, IntType x, IntType c) {
|
static SPROUT_CONSTEXPR IntType mult_add(IntType a, IntType x, IntType c) {
|
||||||
return ((unsigned_m() - 1) & unsigned_m()) == 0 ? (unsigned_type(a) * unsigned_type(x) + unsigned_type(c)) & (unsigned_m() - 1)
|
return ((unsigned_m() - 1) & unsigned_m()) == 0 ? (unsigned_type(a) * unsigned_type(x) + unsigned_type(c)) & (unsigned_m() - 1)
|
||||||
: a == 0 ? c
|
: a == 0 ? c
|
||||||
: m <= (std::numeric_limits<IntType>::max() - c) / a ? (a * x + c) % (m + supress_warnings)
|
: m <= (sprout::numeric_limits<IntType>::max() - c) / a ? (a * x + c) % (m + supress_warnings)
|
||||||
: add(mult(a, x), c)
|
: add(mult(a, x), c)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#define SPROUT_RANDOM_DETAIL_GENERATOR_BITS_HPP
|
#define SPROUT_RANDOM_DETAIL_GENERATOR_BITS_HPP
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <limits>
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
namespace random {
|
namespace random {
|
||||||
|
@ -12,7 +12,7 @@ namespace sprout {
|
||||||
struct generator_bits {
|
struct generator_bits {
|
||||||
public:
|
public:
|
||||||
static SPROUT_CONSTEXPR std::size_t value() {
|
static SPROUT_CONSTEXPR std::size_t value() {
|
||||||
return std::numeric_limits<typename URNG::result_type>::digits;
|
return sprout::numeric_limits<typename URNG::result_type>::digits;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
#ifndef SPROUT_RANDOM_DETAIL_SIGNED_UNSIGNED_TOOLS_HPP
|
#ifndef SPROUT_RANDOM_DETAIL_SIGNED_UNSIGNED_TOOLS_HPP
|
||||||
#define SPROUT_RANDOM_DETAIL_SIGNED_UNSIGNED_TOOLS_HPP
|
#define SPROUT_RANDOM_DETAIL_SIGNED_UNSIGNED_TOOLS_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
namespace random {
|
namespace random {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T, bool B = std::numeric_limits<T>::is_signed>
|
template<typename T, bool B = sprout::numeric_limits<T>::is_signed>
|
||||||
struct subtract {};
|
struct subtract {};
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct subtract<T, false> {
|
struct subtract<T, false> {
|
||||||
|
@ -32,7 +32,7 @@ namespace sprout {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T1, typename T2, bool B = std::numeric_limits<T2>::is_signed>
|
template<typename T1, typename T2, bool B = sprout::numeric_limits<T2>::is_signed>
|
||||||
struct add {};
|
struct add {};
|
||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
struct add<T1, T2, false> {
|
struct add<T1, T2, false> {
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/random/random_result.hpp>
|
#include <sprout/random/random_result.hpp>
|
||||||
#include <sprout/random/detail/generator_bits.hpp>
|
#include <sprout/random/detail/generator_bits.hpp>
|
||||||
#include <sprout/detail/integer.hpp>
|
#include <sprout/detail/integer.hpp>
|
||||||
|
@ -19,9 +19,9 @@ namespace sprout {
|
||||||
typedef URNG base_type;
|
typedef URNG base_type;
|
||||||
typedef typename base_type::result_type base_result;
|
typedef typename base_type::result_type base_result;
|
||||||
typedef typename sprout::detail::uint_t<
|
typedef typename sprout::detail::uint_t<
|
||||||
(std::numeric_limits<std::uintmax_t>::digits < std::numeric_limits<base_result>::digits)
|
(sprout::numeric_limits<std::uintmax_t>::digits < sprout::numeric_limits<base_result>::digits)
|
||||||
? std::numeric_limits<std::uintmax_t>::digits
|
? sprout::numeric_limits<std::uintmax_t>::digits
|
||||||
: std::numeric_limits<base_result>::digits
|
: sprout::numeric_limits<base_result>::digits
|
||||||
>::fast result_type;
|
>::fast result_type;
|
||||||
private:
|
private:
|
||||||
base_type rng_;
|
base_type rng_;
|
||||||
|
@ -39,7 +39,7 @@ namespace sprout {
|
||||||
return (
|
return (
|
||||||
result_type(2) << (
|
result_type(2) << (
|
||||||
NS_SSCRISK_CEL_OR_SPROUT::min(
|
NS_SSCRISK_CEL_OR_SPROUT::min(
|
||||||
std::numeric_limits<result_type>::digits,
|
sprout::numeric_limits<result_type>::digits,
|
||||||
sprout::random::detail::generator_bits<base_type>::value()
|
sprout::random::detail::generator_bits<base_type>::value()
|
||||||
) - 1
|
) - 1
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#define SPROUT_RANDOM_GEOMETRIC_DISTRIBUTION_HPP
|
#define SPROUT_RANDOM_GEOMETRIC_DISTRIBUTION_HPP
|
||||||
|
|
||||||
#include <ios>
|
#include <ios>
|
||||||
#include <limits>
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/log.hpp>
|
#include <sprout/math/log.hpp>
|
||||||
#include <sprout/math/floor.hpp>
|
#include <sprout/math/floor.hpp>
|
||||||
#include <sprout/random/random_result.hpp>
|
#include <sprout/random/random_result.hpp>
|
||||||
|
@ -112,7 +112,7 @@ namespace sprout {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
|
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
|
||||||
return std::numeric_limits<result_type>::max();
|
return sprout::numeric_limits<result_type>::max();
|
||||||
}
|
}
|
||||||
SPROUT_CONSTEXPR param_type param() const SPROUT_NOEXCEPT {
|
SPROUT_CONSTEXPR param_type param() const SPROUT_NOEXCEPT {
|
||||||
return param_type(p_);
|
return param_type(p_);
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
#define SPROUT_RANDOM_INVERSIVE_CONGRUENTIAL_HPP
|
#define SPROUT_RANDOM_INVERSIVE_CONGRUENTIAL_HPP
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
|
||||||
#include <ios>
|
#include <ios>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/random/detail/const_mod.hpp>
|
#include <sprout/random/detail/const_mod.hpp>
|
||||||
#include <sprout/random/random_result.hpp>
|
#include <sprout/random/random_result.hpp>
|
||||||
#include <sprout/math/comparison.hpp>
|
#include <sprout/math/comparison.hpp>
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
#define SPROUT_RANDOM_LINEAR_CONGRUENTIAL_HPP
|
#define SPROUT_RANDOM_LINEAR_CONGRUENTIAL_HPP
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
|
||||||
#include <ios>
|
#include <ios>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/random/detail/const_mod.hpp>
|
#include <sprout/random/detail/const_mod.hpp>
|
||||||
#include <sprout/random/random_result.hpp>
|
#include <sprout/random/random_result.hpp>
|
||||||
#include <sprout/math/comparison.hpp>
|
#include <sprout/math/comparison.hpp>
|
||||||
|
@ -18,7 +18,7 @@ namespace sprout {
|
||||||
//
|
//
|
||||||
template<typename UIntType, UIntType a, UIntType c, UIntType m>
|
template<typename UIntType, UIntType a, UIntType c, UIntType m>
|
||||||
class linear_congruential_engine {
|
class linear_congruential_engine {
|
||||||
static_assert(std::numeric_limits<UIntType>::is_integer, "std::numeric_limits<UIntType>::is_integer");
|
static_assert(sprout::numeric_limits<UIntType>::is_integer, "sprout::numeric_limits<UIntType>::is_integer");
|
||||||
static_assert(m == 0 || a < m, "m == 0 || a < m");
|
static_assert(m == 0 || a < m, "m == 0 || a < m");
|
||||||
static_assert(m == 0 || c < m, "m == 0 || c < m");
|
static_assert(m == 0 || c < m, "m == 0 || c < m");
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef SPROUT_RANDOM_NORMAL_DISTRIBUTION_HPP
|
#ifndef SPROUT_RANDOM_NORMAL_DISTRIBUTION_HPP
|
||||||
#define SPROUT_RANDOM_NORMAL_DISTRIBUTION_HPP
|
#define SPROUT_RANDOM_NORMAL_DISTRIBUTION_HPP
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <ios>
|
#include <ios>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/math/constants.hpp>
|
#include <sprout/math/constants.hpp>
|
||||||
#include <sprout/math/sin.hpp>
|
#include <sprout/math/sin.hpp>
|
||||||
#include <sprout/math/cos.hpp>
|
#include <sprout/math/cos.hpp>
|
||||||
|
@ -185,10 +185,10 @@ namespace sprout {
|
||||||
return sigma_;
|
return sigma_;
|
||||||
}
|
}
|
||||||
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
|
SPROUT_CONSTEXPR result_type min() const SPROUT_NOEXCEPT {
|
||||||
return -std::numeric_limits<RealType>::infinity();
|
return -sprout::numeric_limits<RealType>::infinity();
|
||||||
}
|
}
|
||||||
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
|
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
|
||||||
return std::numeric_limits<RealType>::infinity();
|
return sprout::numeric_limits<RealType>::infinity();
|
||||||
}
|
}
|
||||||
SPROUT_CONSTEXPR param_type param() const SPROUT_NOEXCEPT {
|
SPROUT_CONSTEXPR param_type param() const SPROUT_NOEXCEPT {
|
||||||
return param_type(mean_, sigma_);
|
return param_type(mean_, sigma_);
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
|
||||||
#include <ios>
|
#include <ios>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/array/array.hpp>
|
#include <sprout/array/array.hpp>
|
||||||
#include <sprout/operation/fixed/set.hpp>
|
#include <sprout/operation/fixed/set.hpp>
|
||||||
#include <sprout/math/compare.hpp>
|
#include <sprout/math/compare.hpp>
|
||||||
|
@ -38,8 +38,8 @@ namespace sprout {
|
||||||
: private sprout::random::detail::shuffle_order_engine_member<UniformRandomNumberGenerator, k>
|
: private sprout::random::detail::shuffle_order_engine_member<UniformRandomNumberGenerator, k>
|
||||||
{
|
{
|
||||||
static_assert(
|
static_assert(
|
||||||
std::numeric_limits<typename UniformRandomNumberGenerator::result_type>::is_integer,
|
sprout::numeric_limits<typename UniformRandomNumberGenerator::result_type>::is_integer,
|
||||||
"std::numeric_limits<typename UniformRandomNumberGenerator::result_type>::is_integer"
|
"sprout::numeric_limits<typename UniformRandomNumberGenerator::result_type>::is_integer"
|
||||||
);
|
);
|
||||||
static_assert(k > 0, "k > 0");
|
static_assert(k > 0, "k > 0");
|
||||||
private:
|
private:
|
||||||
|
@ -113,8 +113,8 @@ namespace sprout {
|
||||||
return generate_1(
|
return generate_1(
|
||||||
rng_(),
|
rng_(),
|
||||||
k == 1 ? BaseUnsigned(0)
|
k == 1 ? BaseUnsigned(0)
|
||||||
: sprout::math::less(brange, std::numeric_limits<BaseUnsigned>::max() / k) ? BaseUnsigned(k * off / (brange + 1))
|
: sprout::math::less(brange, sprout::numeric_limits<BaseUnsigned>::max() / k) ? BaseUnsigned(k * off / (brange + 1))
|
||||||
: sprout::math::less(brange, std::numeric_limits<std::uintmax_t>::max() / k)
|
: sprout::math::less(brange, sprout::numeric_limits<std::uintmax_t>::max() / k)
|
||||||
? static_cast<BaseUnsigned>(static_cast<std::uintmax_t>(off) * k / (static_cast<std::uintmax_t>(brange) + 1))
|
? static_cast<BaseUnsigned>(static_cast<std::uintmax_t>(off) * k / (static_cast<std::uintmax_t>(brange) + 1))
|
||||||
//: static_cast<BaseUnsigned>(sprout::random::detail::muldiv(off, k, static_cast<std::uintmax_t>(brange) + 1)) // ???
|
//: static_cast<BaseUnsigned>(sprout::random::detail::muldiv(off, k, static_cast<std::uintmax_t>(brange) + 1)) // ???
|
||||||
: (SPROUT_ASSERT_MSG(0, "Sorry, not implemented."), sprout::random::random_result<shuffle_order_engine>())
|
: (SPROUT_ASSERT_MSG(0, "Sorry, not implemented."), sprout::random::random_result<shuffle_order_engine>())
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <limits>
|
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/limits.hpp>
|
||||||
#include <sprout/random/random_result.hpp>
|
#include <sprout/random/random_result.hpp>
|
||||||
#ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE
|
#ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE
|
||||||
# include <sprout/workaround/recursive_function_template.hpp>
|
# include <sprout/workaround/recursive_function_template.hpp>
|
||||||
|
@ -76,7 +76,7 @@ namespace sprout {
|
||||||
result_type(rnd.result() - eng.min()) * (
|
result_type(rnd.result() - eng.min()) * (
|
||||||
result_type(1) / (
|
result_type(1) / (
|
||||||
result_type(eng.max() - eng.min()) + result_type(
|
result_type(eng.max() - eng.min()) + result_type(
|
||||||
std::numeric_limits<base_result>::is_integer ? 1 : 0
|
sprout::numeric_limits<base_result>::is_integer ? 1 : 0
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -106,7 +106,7 @@ namespace sprout {
|
||||||
result_type(rnd.result() - eng.min()) * (
|
result_type(rnd.result() - eng.min()) * (
|
||||||
result_type(1) / (
|
result_type(1) / (
|
||||||
result_type(eng.max() - eng.min()) + result_type(
|
result_type(eng.max() - eng.min()) + result_type(
|
||||||
std::numeric_limits<base_result>::is_integer ? 1 : 0
|
sprout::numeric_limits<base_result>::is_integer ? 1 : 0
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue