mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
add compost utility
This commit is contained in:
parent
24d2a229f3
commit
b44f7c8f2a
14 changed files with 670 additions and 29 deletions
29
sprout/compost/utility/rosenberg.hpp
Normal file
29
sprout/compost/utility/rosenberg.hpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#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 波は,声門開大期と閉小期が周期の40%,16%となる非対称形の波形であり,τ1 が開大期,τ2が閉小期を示す.
|
||||
//
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue