mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2024-11-12 21:09:01 +00:00
30 lines
1 KiB
C++
30 lines
1 KiB
C++
|
#ifndef SPROUT_COMPOST_UTILITY_ROSENBERG_HPP
|
|||
|
#define SPROUT_COMPOST_UTILITY_ROSENBERG_HPP
|
|||
|
|
|||
|
#include <sprout/config.hpp>
|
|||
|
#include <sprout/detail/pow.hpp>
|
|||
|
#include <sprout/type_traits/float_promote.hpp>
|
|||
|
#include <sprout/math/comparison.hpp>
|
|||
|
|
|||
|
namespace sprout {
|
|||
|
namespace compost {
|
|||
|
//
|
|||
|
// rosenberg_value
|
|||
|
// Rosenberg <20>g<EFBFBD>́C<CD81><43><EFBFBD><EFBFBD><EFBFBD>J<EFBFBD><4A><EFBFBD><EFBFBD><EFBFBD>ƕ<C695><C28F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>40%<25>C16%<25>ƂȂ<C682><C882><EFBFBD><EFBFBD>Ώ̌`<60>̔g<CC94>`<60>ł<EFBFBD><C582><EFBFBD><EFBFBD>C<EFBFBD><43>1 <20><><EFBFBD>J<EFBFBD><4A><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><43>2<EFBFBD><32><EFBFBD><EFBFBD><C28F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>D
|
|||
|
//
|
|||
|
template<typename T>
|
|||
|
inline SPROUT_CONSTEXPR typename sprout::float_promote<T>::type
|
|||
|
rosenberg_value(T x, T tau1, T tau2) {
|
|||
|
typedef typename sprout::float_promote<T>::type type;
|
|||
|
return x >= 0 && sprout::math::less_equal(x, tau1)
|
|||
|
? 3 * sprout::detail::pow2<type>(x / tau1) - 2 * sprout::detail::pow3<type>(x / tau1)
|
|||
|
: sprout::math::greater(x, tau1) && sprout::math::less_equal(x, tau1 + tau2)
|
|||
|
? 1 - sprout::detail::pow2<type>((x - tau1) / tau2)
|
|||
|
: 0
|
|||
|
;
|
|||
|
}
|
|||
|
} // namespace compost
|
|||
|
} // namespace sprout
|
|||
|
|
|||
|
#endif // #ifndef SPROUT_COMPOST_UTILITY_ROSENBERG_HPP
|