mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
add math tgamma
This commit is contained in:
parent
f461643582
commit
a55c430f09
10 changed files with 224 additions and 40 deletions
|
@ -28,6 +28,12 @@ namespace sprout {
|
||||||
//
|
//
|
||||||
// begin
|
// begin
|
||||||
//
|
//
|
||||||
|
// effect:
|
||||||
|
// ADL callable range_begin(cont) -> range_begin(cont)
|
||||||
|
// otherwise -> sprout::container_range_traits<Container>::range_begin(cont)
|
||||||
|
// [default]
|
||||||
|
// cont.begin()
|
||||||
|
//
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||||
begin(Container& cont) {
|
begin(Container& cont) {
|
||||||
|
@ -59,14 +65,12 @@ namespace sprout {
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||||
cbegin(Container const& cont) {
|
cbegin(Container const& cont) {
|
||||||
using sprout::container_detail::range_begin;
|
return sprout::begin(cont);
|
||||||
using sprout_adl::range_begin;
|
|
||||||
return range_begin(cont);
|
|
||||||
}
|
}
|
||||||
template<typename T, std::size_t N>
|
template<typename T, std::size_t N>
|
||||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
|
||||||
cbegin(T const (& arr)[N]) {
|
cbegin(T const (& arr)[N]) {
|
||||||
return sprout::container_detail::range_begin(arr);
|
return sprout::begin(arr);
|
||||||
}
|
}
|
||||||
} // namespace sprout
|
} // namespace sprout
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,12 @@ namespace sprout {
|
||||||
//
|
//
|
||||||
// end
|
// end
|
||||||
//
|
//
|
||||||
|
// effect:
|
||||||
|
// ADL callable range_end(cont) -> range_end(cont)
|
||||||
|
// otherwise -> sprout::container_range_traits<Container>::range_end(cont)
|
||||||
|
// [default]
|
||||||
|
// cont.end()
|
||||||
|
//
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||||
end(Container& cont) {
|
end(Container& cont) {
|
||||||
|
@ -59,14 +65,12 @@ namespace sprout {
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||||
cend(Container const& cont) {
|
cend(Container const& cont) {
|
||||||
using sprout::container_detail::range_end;
|
return sprout::end(cont);
|
||||||
using sprout_adl::range_end;
|
|
||||||
return range_end(cont);
|
|
||||||
}
|
}
|
||||||
template<typename T, std::size_t N>
|
template<typename T, std::size_t N>
|
||||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
|
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
|
||||||
cend(T const (& arr)[N]) {
|
cend(T const (& arr)[N]) {
|
||||||
return sprout::container_detail::range_end(arr);
|
return sprout::end(arr);
|
||||||
}
|
}
|
||||||
} // namespace sprout
|
} // namespace sprout
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,13 @@ namespace sprout {
|
||||||
//
|
//
|
||||||
// to_hash
|
// to_hash
|
||||||
//
|
//
|
||||||
|
// effect:
|
||||||
|
// ADL callable hash_value(v) -> hash_value(v)
|
||||||
|
// otherwise -> sprout::hash_value_traits<T>::hash_value(v)
|
||||||
|
// [default]
|
||||||
|
// v is Arithmetic || Enum || Pointer || Array -> implementation-defined
|
||||||
|
// otherwise -> std::hash<T>()(v)
|
||||||
|
//
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline SPROUT_CONSTEXPR std::size_t
|
inline SPROUT_CONSTEXPR std::size_t
|
||||||
to_hash(T&& v) {
|
to_hash(T&& v) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace sprout_generator_detail {
|
||||||
template<typename Gen>
|
template<typename Gen>
|
||||||
inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen>::get_generated_value(std::declval<Gen&>()))
|
inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen>::get_generated_value(std::declval<Gen&>()))
|
||||||
get_generated_value(Gen& gen)
|
get_generated_value(Gen& gen)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen>::get_generated_value(std::declval<Gen&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen>::get_generated_value(std::declval<Gen&>())))
|
||||||
{
|
{
|
||||||
return sprout::generators::generator_access_traits<Gen>::get_generated_value(gen);
|
return sprout::generators::generator_access_traits<Gen>::get_generated_value(gen);
|
||||||
}
|
}
|
||||||
|
@ -28,14 +28,14 @@ namespace sprout_generator_detail {
|
||||||
decltype(sprout::generators::generator_access_traits<typename std::remove_reference<Gen>::type>::get_generated_value(std::declval<Gen&&>()))
|
decltype(sprout::generators::generator_access_traits<typename std::remove_reference<Gen>::type>::get_generated_value(std::declval<Gen&&>()))
|
||||||
>::type
|
>::type
|
||||||
get_generated_value(Gen&& gen)
|
get_generated_value(Gen&& gen)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<typename std::remove_reference<Gen>::type>::get_generated_value(std::declval<Gen&&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<typename std::remove_reference<Gen>::type>::get_generated_value(std::declval<Gen&&>())))
|
||||||
{
|
{
|
||||||
return sprout::generators::generator_access_traits<Gen>::get_generated_value(gen);
|
return sprout::generators::generator_access_traits<Gen>::get_generated_value(gen);
|
||||||
}
|
}
|
||||||
template<typename Gen>
|
template<typename Gen>
|
||||||
inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen const>::get_generated_value(std::declval<Gen const&>()))
|
inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen const>::get_generated_value(std::declval<Gen const&>()))
|
||||||
get_generated_value(Gen const& gen)
|
get_generated_value(Gen const& gen)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen const>::get_generated_value(std::declval<Gen const&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen const>::get_generated_value(std::declval<Gen const&>())))
|
||||||
{
|
{
|
||||||
return sprout::generators::generator_access_traits<Gen const>::get_generated_value(gen);
|
return sprout::generators::generator_access_traits<Gen const>::get_generated_value(gen);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ namespace sprout_generator_detail {
|
||||||
template<typename Gen>
|
template<typename Gen>
|
||||||
inline SPROUT_CONSTEXPR decltype(get_generated_value(std::declval<Gen&>()))
|
inline SPROUT_CONSTEXPR decltype(get_generated_value(std::declval<Gen&>()))
|
||||||
call_get_generated_value(Gen& gen)
|
call_get_generated_value(Gen& gen)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_generated_value(std::declval<Gen&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_generated_value(std::declval<Gen&>())))
|
||||||
{
|
{
|
||||||
return get_generated_value(gen);
|
return get_generated_value(gen);
|
||||||
}
|
}
|
||||||
|
@ -53,14 +53,14 @@ namespace sprout_generator_detail {
|
||||||
decltype(get_generated_value(std::declval<Gen&&>()))
|
decltype(get_generated_value(std::declval<Gen&&>()))
|
||||||
>::type
|
>::type
|
||||||
call_get_generated_value(Gen&& gen)
|
call_get_generated_value(Gen&& gen)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_generated_value(std::declval<Gen&&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_generated_value(std::declval<Gen&&>())))
|
||||||
{
|
{
|
||||||
return get_generated_value(gen);
|
return get_generated_value(gen);
|
||||||
}
|
}
|
||||||
template<typename Gen>
|
template<typename Gen>
|
||||||
inline SPROUT_CONSTEXPR decltype(get_generated_value(std::declval<Gen const&>()))
|
inline SPROUT_CONSTEXPR decltype(get_generated_value(std::declval<Gen const&>()))
|
||||||
call_get_generated_value(Gen const& gen)
|
call_get_generated_value(Gen const& gen)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_generated_value(std::declval<Gen const&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_generated_value(std::declval<Gen const&>())))
|
||||||
{
|
{
|
||||||
return get_generated_value(gen);
|
return get_generated_value(gen);
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,13 @@ namespace sprout {
|
||||||
//
|
//
|
||||||
// generated_value
|
// generated_value
|
||||||
//
|
//
|
||||||
|
// effect:
|
||||||
|
// ADL callable get_generated_value(t) -> get_generated_value(t)
|
||||||
|
// otherwise -> sprout::generators::generator_access_traits<T>::get_generated_value(t)
|
||||||
|
// [default]
|
||||||
|
// member callable t.generated_value() -> t.generated_value()
|
||||||
|
// otherwise -> sprout::tuples::get<0>(t)
|
||||||
|
//
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline SPROUT_CONSTEXPR decltype(sprout_generator_detail::call_get_generated_value(std::declval<T>()))
|
inline SPROUT_CONSTEXPR decltype(sprout_generator_detail::call_get_generated_value(std::declval<T>()))
|
||||||
generated_value(T&& t)
|
generated_value(T&& t)
|
||||||
|
|
|
@ -41,19 +41,19 @@ namespace sprout {
|
||||||
public:
|
public:
|
||||||
static SPROUT_CONSTEXPR decltype(std::declval<Gen&>().generated_value())
|
static SPROUT_CONSTEXPR decltype(std::declval<Gen&>().generated_value())
|
||||||
get_generated_value(Gen& t)
|
get_generated_value(Gen& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<Gen&>().generated_value()))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<Gen&>().generated_value()))
|
||||||
{
|
{
|
||||||
return t.generated_value();
|
return t.generated_value();
|
||||||
}
|
}
|
||||||
static SPROUT_CONSTEXPR decltype(std::declval<Gen&&>().generated_value())
|
static SPROUT_CONSTEXPR decltype(std::declval<Gen&&>().generated_value())
|
||||||
get_generated_value(Gen&& t)
|
get_generated_value(Gen&& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<Gen&&>().generated_value()))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<Gen&&>().generated_value()))
|
||||||
{
|
{
|
||||||
return t.generated_value();
|
return t.generated_value();
|
||||||
}
|
}
|
||||||
static SPROUT_CONSTEXPR decltype(std::declval<Gen const&>().generated_value())
|
static SPROUT_CONSTEXPR decltype(std::declval<Gen const&>().generated_value())
|
||||||
get_generated_value(Gen const& t)
|
get_generated_value(Gen const& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<Gen const&>().generated_value()))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<Gen const&>().generated_value()))
|
||||||
{
|
{
|
||||||
return t.generated_value();
|
return t.generated_value();
|
||||||
}
|
}
|
||||||
|
@ -66,19 +66,19 @@ namespace sprout {
|
||||||
public:
|
public:
|
||||||
static SPROUT_CONSTEXPR decltype(sprout::tuples::get<0>(std::declval<Gen&>()))
|
static SPROUT_CONSTEXPR decltype(sprout::tuples::get<0>(std::declval<Gen&>()))
|
||||||
get_generated_value(Gen& t)
|
get_generated_value(Gen& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<0>(std::declval<Gen&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<0>(std::declval<Gen&>())))
|
||||||
{
|
{
|
||||||
return sprout::tuples::get<0>(t);
|
return sprout::tuples::get<0>(t);
|
||||||
}
|
}
|
||||||
static SPROUT_CONSTEXPR decltype(sprout::tuples::get<0>(std::declval<Gen&&>()))
|
static SPROUT_CONSTEXPR decltype(sprout::tuples::get<0>(std::declval<Gen&&>()))
|
||||||
get_generated_value(Gen&& t)
|
get_generated_value(Gen&& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<0>(std::declval<Gen&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<0>(std::declval<Gen&>())))
|
||||||
{
|
{
|
||||||
return sprout::tuples::get<0>(t);
|
return sprout::tuples::get<0>(t);
|
||||||
}
|
}
|
||||||
static SPROUT_CONSTEXPR decltype(sprout::tuples::get<0>(std::declval<Gen const&>()))
|
static SPROUT_CONSTEXPR decltype(sprout::tuples::get<0>(std::declval<Gen const&>()))
|
||||||
get_generated_value(Gen const& t)
|
get_generated_value(Gen const& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<0>(std::declval<Gen const&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<0>(std::declval<Gen const&>())))
|
||||||
{
|
{
|
||||||
return sprout::tuples::get<0>(t);
|
return sprout::tuples::get<0>(t);
|
||||||
}
|
}
|
||||||
|
@ -116,19 +116,19 @@ namespace sprout {
|
||||||
public:
|
public:
|
||||||
static SPROUT_CONSTEXPR decltype(std::declval<Gen&>().next_generator())
|
static SPROUT_CONSTEXPR decltype(std::declval<Gen&>().next_generator())
|
||||||
get_next_generator(Gen& t)
|
get_next_generator(Gen& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<Gen&>().next_generator()))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<Gen&>().next_generator()))
|
||||||
{
|
{
|
||||||
return t.next_generator();
|
return t.next_generator();
|
||||||
}
|
}
|
||||||
static SPROUT_CONSTEXPR decltype(std::declval<Gen&&>().next_generator())
|
static SPROUT_CONSTEXPR decltype(std::declval<Gen&&>().next_generator())
|
||||||
get_next_generator(Gen&& t)
|
get_next_generator(Gen&& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<Gen&&>().next_generator()))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<Gen&&>().next_generator()))
|
||||||
{
|
{
|
||||||
return t.next_generator();
|
return t.next_generator();
|
||||||
}
|
}
|
||||||
static SPROUT_CONSTEXPR decltype(std::declval<Gen const&>().next_generator())
|
static SPROUT_CONSTEXPR decltype(std::declval<Gen const&>().next_generator())
|
||||||
get_next_generator(Gen const& t)
|
get_next_generator(Gen const& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<Gen const&>().next_generator()))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<Gen const&>().next_generator()))
|
||||||
{
|
{
|
||||||
return t.next_generator();
|
return t.next_generator();
|
||||||
}
|
}
|
||||||
|
@ -141,19 +141,19 @@ namespace sprout {
|
||||||
public:
|
public:
|
||||||
static SPROUT_CONSTEXPR decltype(sprout::tuples::get<1>(std::declval<Gen&>()))
|
static SPROUT_CONSTEXPR decltype(sprout::tuples::get<1>(std::declval<Gen&>()))
|
||||||
get_next_generator(Gen& t)
|
get_next_generator(Gen& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<1>(std::declval<Gen&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<1>(std::declval<Gen&>())))
|
||||||
{
|
{
|
||||||
return sprout::tuples::get<1>(t);
|
return sprout::tuples::get<1>(t);
|
||||||
}
|
}
|
||||||
static SPROUT_CONSTEXPR decltype(sprout::tuples::get<1>(std::declval<Gen&&>()))
|
static SPROUT_CONSTEXPR decltype(sprout::tuples::get<1>(std::declval<Gen&&>()))
|
||||||
get_next_generator(Gen&& t)
|
get_next_generator(Gen&& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<1>(std::declval<Gen&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<1>(std::declval<Gen&>())))
|
||||||
{
|
{
|
||||||
return sprout::tuples::get<1>(t);
|
return sprout::tuples::get<1>(t);
|
||||||
}
|
}
|
||||||
static SPROUT_CONSTEXPR decltype(sprout::tuples::get<1>(std::declval<Gen const&>()))
|
static SPROUT_CONSTEXPR decltype(sprout::tuples::get<1>(std::declval<Gen const&>()))
|
||||||
get_next_generator(Gen const& t)
|
get_next_generator(Gen const& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<1>(std::declval<Gen const&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<1>(std::declval<Gen const&>())))
|
||||||
{
|
{
|
||||||
return sprout::tuples::get<1>(t);
|
return sprout::tuples::get<1>(t);
|
||||||
}
|
}
|
||||||
|
@ -173,13 +173,13 @@ namespace sprout {
|
||||||
public:
|
public:
|
||||||
static SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen>::get_generated_value(std::declval<Gen const&>()))
|
static SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen>::get_generated_value(std::declval<Gen const&>()))
|
||||||
get_generated_value(Gen const& t)
|
get_generated_value(Gen const& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen>::get_generated_value(std::declval<Gen const&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen>::get_generated_value(std::declval<Gen const&>())))
|
||||||
{
|
{
|
||||||
return sprout::generators::generator_access_traits<Gen>::get_generated_value(t);
|
return sprout::generators::generator_access_traits<Gen>::get_generated_value(t);
|
||||||
}
|
}
|
||||||
static SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen>::get_next_generator(std::declval<Gen const&>()))
|
static SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen>::get_next_generator(std::declval<Gen const&>()))
|
||||||
get_next_generator(Gen const& t)
|
get_next_generator(Gen const& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen>::get_next_generator(std::declval<Gen const&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen>::get_next_generator(std::declval<Gen const&>())))
|
||||||
{
|
{
|
||||||
return sprout::generators::generator_access_traits<Gen>::get_next_generator(t);
|
return sprout::generators::generator_access_traits<Gen>::get_next_generator(t);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace sprout_generator_detail {
|
||||||
template<typename Gen>
|
template<typename Gen>
|
||||||
inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen>::get_next_generator(std::declval<Gen&>()))
|
inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen>::get_next_generator(std::declval<Gen&>()))
|
||||||
get_next_generator(Gen& gen)
|
get_next_generator(Gen& gen)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen>::get_next_generator(std::declval<Gen&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen>::get_next_generator(std::declval<Gen&>())))
|
||||||
{
|
{
|
||||||
return sprout::generators::generator_access_traits<Gen>::get_next_generator(gen);
|
return sprout::generators::generator_access_traits<Gen>::get_next_generator(gen);
|
||||||
}
|
}
|
||||||
|
@ -28,14 +28,14 @@ namespace sprout_generator_detail {
|
||||||
decltype(sprout::generators::generator_access_traits<typename std::remove_reference<Gen>::type>::get_next_generator(std::declval<Gen&&>()))
|
decltype(sprout::generators::generator_access_traits<typename std::remove_reference<Gen>::type>::get_next_generator(std::declval<Gen&&>()))
|
||||||
>::type
|
>::type
|
||||||
get_next_generator(Gen&& gen)
|
get_next_generator(Gen&& gen)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<typename std::remove_reference<Gen>::type>::get_next_generator(std::declval<Gen&&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<typename std::remove_reference<Gen>::type>::get_next_generator(std::declval<Gen&&>())))
|
||||||
{
|
{
|
||||||
return sprout::generators::generator_access_traits<Gen>::get_next_generator(gen);
|
return sprout::generators::generator_access_traits<Gen>::get_next_generator(gen);
|
||||||
}
|
}
|
||||||
template<typename Gen>
|
template<typename Gen>
|
||||||
inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen const>::get_next_generator(std::declval<Gen const&>()))
|
inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen const>::get_next_generator(std::declval<Gen const&>()))
|
||||||
get_next_generator(Gen const& gen)
|
get_next_generator(Gen const& gen)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen const>::get_next_generator(std::declval<Gen const&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen const>::get_next_generator(std::declval<Gen const&>())))
|
||||||
{
|
{
|
||||||
return sprout::generators::generator_access_traits<Gen const>::get_next_generator(gen);
|
return sprout::generators::generator_access_traits<Gen const>::get_next_generator(gen);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ namespace sprout_generator_detail {
|
||||||
template<typename Gen>
|
template<typename Gen>
|
||||||
inline SPROUT_CONSTEXPR decltype(get_next_generator(std::declval<Gen&>()))
|
inline SPROUT_CONSTEXPR decltype(get_next_generator(std::declval<Gen&>()))
|
||||||
call_get_next_generator(Gen& gen)
|
call_get_next_generator(Gen& gen)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_next_generator(std::declval<Gen&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_next_generator(std::declval<Gen&>())))
|
||||||
{
|
{
|
||||||
return get_next_generator(gen);
|
return get_next_generator(gen);
|
||||||
}
|
}
|
||||||
|
@ -53,14 +53,14 @@ namespace sprout_generator_detail {
|
||||||
decltype(get_next_generator(std::declval<Gen&&>()))
|
decltype(get_next_generator(std::declval<Gen&&>()))
|
||||||
>::type
|
>::type
|
||||||
call_get_next_generator(Gen&& gen)
|
call_get_next_generator(Gen&& gen)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_next_generator(std::declval<Gen&&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_next_generator(std::declval<Gen&&>())))
|
||||||
{
|
{
|
||||||
return get_next_generator(gen);
|
return get_next_generator(gen);
|
||||||
}
|
}
|
||||||
template<typename Gen>
|
template<typename Gen>
|
||||||
inline SPROUT_CONSTEXPR decltype(get_next_generator(std::declval<Gen const&>()))
|
inline SPROUT_CONSTEXPR decltype(get_next_generator(std::declval<Gen const&>()))
|
||||||
call_get_next_generator(Gen const& gen)
|
call_get_next_generator(Gen const& gen)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_next_generator(std::declval<Gen const&>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(get_next_generator(std::declval<Gen const&>())))
|
||||||
{
|
{
|
||||||
return get_next_generator(gen);
|
return get_next_generator(gen);
|
||||||
}
|
}
|
||||||
|
@ -71,10 +71,17 @@ namespace sprout {
|
||||||
//
|
//
|
||||||
// next_generator
|
// next_generator
|
||||||
//
|
//
|
||||||
|
// effect:
|
||||||
|
// ADL callable get_next_generator(t) -> get_next_generator(t)
|
||||||
|
// otherwise -> sprout::generators::generator_access_traits<T>::get_next_generator(t)
|
||||||
|
// [default]
|
||||||
|
// member callable t.next_generator() -> t.next_generator()
|
||||||
|
// otherwise -> sprout::tuples::get<0>(t)
|
||||||
|
//
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline SPROUT_CONSTEXPR decltype(sprout_generator_detail::call_get_next_generator(std::declval<T>()))
|
inline SPROUT_CONSTEXPR decltype(sprout_generator_detail::call_get_next_generator(std::declval<T>()))
|
||||||
next_generator(T&& t)
|
next_generator(T&& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout_generator_detail::call_get_next_generator(std::declval<T>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout_generator_detail::call_get_next_generator(std::declval<T>())))
|
||||||
{
|
{
|
||||||
return sprout_generator_detail::call_get_next_generator(sprout::forward<T>(t));
|
return sprout_generator_detail::call_get_next_generator(sprout::forward<T>(t));
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <sprout/math/exponential.hpp>
|
#include <sprout/math/exponential.hpp>
|
||||||
#include <sprout/math/power.hpp>
|
#include <sprout/math/power.hpp>
|
||||||
#include <sprout/math/error.hpp>
|
#include <sprout/math/error.hpp>
|
||||||
|
#include <sprout/math/gamma.hpp>
|
||||||
#include <sprout/math/nearest.hpp>
|
#include <sprout/math/nearest.hpp>
|
||||||
#include <sprout/math/remainders.hpp>
|
#include <sprout/math/remainders.hpp>
|
||||||
#include <sprout/math/minmax.hpp>
|
#include <sprout/math/minmax.hpp>
|
||||||
|
|
7
sprout/math/gamma.hpp
Normal file
7
sprout/math/gamma.hpp
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#ifndef SPROUT_MATH_GAMMA_HPP
|
||||||
|
#define SPROUT_MATH_GAMMA_HPP
|
||||||
|
|
||||||
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/math/tgamma.hpp>
|
||||||
|
|
||||||
|
#endif // #ifndef SPROUT_MATH_GAMMA_HPP
|
141
sprout/math/tgamma.hpp
Normal file
141
sprout/math/tgamma.hpp
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
#ifndef SPROUT_MATH_TGAMMA_HPP
|
||||||
|
#define SPROUT_MATH_TGAMMA_HPP
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <limits>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <sprout/config.hpp>
|
||||||
|
#include <sprout/math/detail/config.hpp>
|
||||||
|
#include <sprout/math/detail/float_compute.hpp>
|
||||||
|
#include <sprout/math/factorial.hpp>
|
||||||
|
#include <sprout/math/iround.hpp>
|
||||||
|
#include <sprout/math/trunc.hpp>
|
||||||
|
#include <sprout/algorithm/clamp.hpp>
|
||||||
|
#include <sprout/type_traits/enabler_if.hpp>
|
||||||
|
#include HDR_ALGORITHM_MIN_MAX_SSCRISK_CEL_OR_SPROUT
|
||||||
|
|
||||||
|
namespace sprout {
|
||||||
|
namespace math {
|
||||||
|
namespace detail {
|
||||||
|
template<typename T>
|
||||||
|
inline SPROUT_CONSTEXPR T
|
||||||
|
tgamma_impl_y(T w) {
|
||||||
|
return ((((((((((((
|
||||||
|
-1.99542863674e-7 * w + 1.337767384067e-6) * w
|
||||||
|
- 2.591225267689e-6) * w - 1.7545539395205e-5) * w
|
||||||
|
+ 1.45596568617526e-4) * w - 3.60837876648255e-4) * w
|
||||||
|
- 8.04329819255744e-4) * w + 0.008023273027855346) * w
|
||||||
|
- 0.017645244547851414) * w - 0.024552490005641278) * w
|
||||||
|
+ 0.19109110138763841) * w - 0.233093736421782878) * w
|
||||||
|
- 0.422784335098466784) * w + 0.99999999999999999
|
||||||
|
;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
inline SPROUT_CONSTEXPR T
|
||||||
|
tgamma_impl_t_pos(T x, std::size_t n, std::size_t last) {
|
||||||
|
return last - n == 1
|
||||||
|
? x - static_cast<T>(n)
|
||||||
|
: sprout::math::detail::tgamma_impl_t_pos(x, n, n + (last - n) / 2)
|
||||||
|
* sprout::math::detail::tgamma_impl_t_pos(x, n + (last - n) / 2, last)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
inline SPROUT_CONSTEXPR T
|
||||||
|
tgamma_impl_t_neg(T x, std::size_t n, std::size_t last) {
|
||||||
|
return last - n == 1
|
||||||
|
? x + static_cast<T>(n)
|
||||||
|
: sprout::math::detail::tgamma_impl_t_neg(x, n, n + (last - n) / 2)
|
||||||
|
* sprout::math::detail::tgamma_impl_t_neg(x, n + (last - n) / 2, last)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
inline SPROUT_CONSTEXPR T
|
||||||
|
tgamma_impl_t_pos_rec(T x, std::size_t n, std::size_t last) {
|
||||||
|
return last - n == 1
|
||||||
|
? T(1) / (x - static_cast<T>(n))
|
||||||
|
: sprout::math::detail::tgamma_impl_t_pos_rec(x, n, n + (last - n) / 2)
|
||||||
|
* sprout::math::detail::tgamma_impl_t_pos_rec(x, n + (last - n) / 2, last)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
inline SPROUT_CONSTEXPR T
|
||||||
|
tgamma_impl_t_neg_rec(T x, std::size_t n, std::size_t last) {
|
||||||
|
return last - n == 1
|
||||||
|
? T(1) / (x + static_cast<T>(n))
|
||||||
|
: sprout::math::detail::tgamma_impl_t_neg_rec(x, n, n + (last - n) / 2)
|
||||||
|
* sprout::math::detail::tgamma_impl_t_neg_rec(x, n + (last - n) / 2, last)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
inline SPROUT_CONSTEXPR T
|
||||||
|
tgamma_impl_2_pos(T x, T y, T t) {
|
||||||
|
return t == 0 ? std::numeric_limits<T>::infinity()
|
||||||
|
: (x - T(1)) / y / t
|
||||||
|
;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
inline SPROUT_CONSTEXPR T
|
||||||
|
tgamma_impl_2_neg(T x, T y, T t) {
|
||||||
|
return t == 0 ? T(0)
|
||||||
|
: T(1) / y * t
|
||||||
|
;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
inline SPROUT_CONSTEXPR T
|
||||||
|
tgamma_impl_1(T x, int n) {
|
||||||
|
return n == 1 ? (x - T(1)) / sprout::math::detail::tgamma_impl_y(x - (n + 2))
|
||||||
|
: n == 0 ? T(1) / sprout::math::detail::tgamma_impl_y(x - (n + 2))
|
||||||
|
: n == static_cast<int>(sprout::math::factorial_limit<T>())
|
||||||
|
? sprout::math::detail::tgamma_impl_2_pos(x, sprout::math::detail::tgamma_impl_y(x - (n + 2)), sprout::math::detail::tgamma_impl_t_pos_rec(x, 2, n + 1))
|
||||||
|
: n == -static_cast<int>(sprout::math::factorial_limit<T>())
|
||||||
|
// ? sprout::math::detail::tgamma_impl_2_neg(x, sprout::math::detail::tgamma_impl_y(x - (n + 2)), sprout::math::detail::tgamma_impl_t_neg_rec(x, 0, -n))
|
||||||
|
? T(1) / sprout::math::detail::tgamma_impl_y(x - (n + 2)) * sprout::math::detail::tgamma_impl_t_neg_rec(x, 0, -n)
|
||||||
|
: n > 1 ? (x - T(1)) / sprout::math::detail::tgamma_impl_y(x - (n + 2)) * sprout::math::detail::tgamma_impl_t_pos(x, 2, n + 1)
|
||||||
|
: T(1) / sprout::math::detail::tgamma_impl_y(x - (n + 2)) / sprout::math::detail::tgamma_impl_t_neg(x, 0, -n)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
template<typename T>
|
||||||
|
inline SPROUT_CONSTEXPR T
|
||||||
|
tgamma_impl(T x) {
|
||||||
|
return sprout::math::detail::tgamma_impl_1(
|
||||||
|
x,
|
||||||
|
sprout::clamp(
|
||||||
|
sprout::math::iround(x - T(2)),
|
||||||
|
-static_cast<int>(sprout::math::factorial_limit<T>()),
|
||||||
|
static_cast<int>(sprout::math::factorial_limit<T>())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<
|
||||||
|
typename FloatType,
|
||||||
|
typename sprout::enabler_if<std::is_floating_point<FloatType>::value>::type = sprout::enabler
|
||||||
|
>
|
||||||
|
inline SPROUT_CONSTEXPR FloatType
|
||||||
|
tgamma(FloatType x) {
|
||||||
|
typedef typename sprout::math::detail::float_compute<FloatType>::type type;
|
||||||
|
return x == 0 ? std::numeric_limits<FloatType>::infinity()
|
||||||
|
: x == -std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::quiet_NaN()
|
||||||
|
: x == std::numeric_limits<FloatType>::infinity() ? std::numeric_limits<FloatType>::infinity()
|
||||||
|
: x < 0 && x == std::trunc(x) ? std::numeric_limits<FloatType>::quiet_NaN()
|
||||||
|
: static_cast<FloatType>(sprout::math::detail::tgamma_impl(static_cast<type>(x)))
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<
|
||||||
|
typename IntType,
|
||||||
|
typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler
|
||||||
|
>
|
||||||
|
inline SPROUT_CONSTEXPR double
|
||||||
|
tgamma(IntType x) {
|
||||||
|
return sprout::math::detail::tgamma(static_cast<double>(x));
|
||||||
|
}
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
using NS_SPROUT_MATH_DETAIL::tgamma;
|
||||||
|
} // namespace math
|
||||||
|
|
||||||
|
using sprout::math::tgamma;
|
||||||
|
} // namespace sprout
|
||||||
|
|
||||||
|
#endif // #ifndef SPROUT_MATH_TGAMMA_HPP
|
|
@ -62,7 +62,7 @@ namespace sprout_tuple_detail {
|
||||||
template<std::size_t I, typename T>
|
template<std::size_t I, typename T>
|
||||||
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, T>::type&
|
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, T>::type&
|
||||||
tuple_get(T& t)
|
tuple_get(T& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::tuple_access_traits<T>::template tuple_get<I>(std::declval<T>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::tuple_access_traits<T>::template tuple_get<I>(std::declval<T>())))
|
||||||
{
|
{
|
||||||
return sprout::tuples::tuple_access_traits<T>::template tuple_get<I>(t);
|
return sprout::tuples::tuple_access_traits<T>::template tuple_get<I>(t);
|
||||||
}
|
}
|
||||||
|
@ -72,14 +72,14 @@ namespace sprout_tuple_detail {
|
||||||
typename sprout::tuples::tuple_element<I, typename std::remove_reference<T>::type>::type&&
|
typename sprout::tuples::tuple_element<I, typename std::remove_reference<T>::type>::type&&
|
||||||
>::type
|
>::type
|
||||||
tuple_get(T&& t)
|
tuple_get(T&& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::tuple_access_traits<typename std::remove_reference<T>::type>::template tuple_get<I>(std::declval<T>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::tuple_access_traits<typename std::remove_reference<T>::type>::template tuple_get<I>(std::declval<T>())))
|
||||||
{
|
{
|
||||||
return sprout::tuples::tuple_access_traits<T>::template tuple_get<I>(t);
|
return sprout::tuples::tuple_access_traits<T>::template tuple_get<I>(t);
|
||||||
}
|
}
|
||||||
template<std::size_t I, typename T>
|
template<std::size_t I, typename T>
|
||||||
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, T>::type const&
|
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, T>::type const&
|
||||||
tuple_get(T const& t)
|
tuple_get(T const& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::tuple_access_traits<T const>::template tuple_get<I>(std::declval<T>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::tuple_access_traits<T const>::template tuple_get<I>(std::declval<T>())))
|
||||||
{
|
{
|
||||||
return sprout::tuples::tuple_access_traits<T const>::template tuple_get<I>(t);
|
return sprout::tuples::tuple_access_traits<T const>::template tuple_get<I>(t);
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ namespace sprout_tuple_detail {
|
||||||
template<std::size_t I, typename T>
|
template<std::size_t I, typename T>
|
||||||
inline SPROUT_CONSTEXPR decltype(tuple_get<I>(std::declval<T>()))
|
inline SPROUT_CONSTEXPR decltype(tuple_get<I>(std::declval<T>()))
|
||||||
call_tuple_get(T&& t)
|
call_tuple_get(T&& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(tuple_get<I>(std::declval<T>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(tuple_get<I>(std::declval<T>())))
|
||||||
{
|
{
|
||||||
return tuple_get<I>(sprout::forward<T>(t));
|
return tuple_get<I>(sprout::forward<T>(t));
|
||||||
}
|
}
|
||||||
|
@ -98,10 +98,16 @@ namespace sprout {
|
||||||
//
|
//
|
||||||
// get
|
// get
|
||||||
//
|
//
|
||||||
|
// effect:
|
||||||
|
// ADL callable tuple_get<I>(t) -> tuple_get<I>(t)
|
||||||
|
// otherwise -> sprout::tuples::tuple_access_traits<T>::tuple_get<I>(t)
|
||||||
|
// [default]
|
||||||
|
// std::get<I>(t)
|
||||||
|
//
|
||||||
template<std::size_t I, typename T>
|
template<std::size_t I, typename T>
|
||||||
inline SPROUT_CONSTEXPR decltype(sprout_tuple_detail::call_tuple_get<I>(std::declval<T>()))
|
inline SPROUT_CONSTEXPR decltype(sprout_tuple_detail::call_tuple_get<I>(std::declval<T>()))
|
||||||
get(T&& t)
|
get(T&& t)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout_tuple_detail::call_tuple_get<I>(std::declval<T>())))
|
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout_tuple_detail::call_tuple_get<I>(std::declval<T>())))
|
||||||
{
|
{
|
||||||
return sprout_tuple_detail::call_tuple_get<I>(sprout::forward<T>(t));
|
return sprout_tuple_detail::call_tuple_get<I>(sprout::forward<T>(t));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue