add math::phi

This commit is contained in:
bolero-MURAKAMI 2014-03-17 17:06:41 +09:00
parent 57d2a8bc21
commit 6e09fc2ee5
3 changed files with 130 additions and 117 deletions

View file

@ -11,5 +11,6 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/math/functions.hpp> #include <sprout/math/functions.hpp>
#include <sprout/math/constants.hpp> #include <sprout/math/constants.hpp>
#include <sprout/math/constant_variables.hpp>
#endif // #ifndef SPROUT_MATH_HPP #endif // #ifndef SPROUT_MATH_HPP

View file

@ -10,108 +10,113 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#if SPROUT_USE_VARIABLE_TEMPLATES #if SPROUT_USE_VARIABLE_TEMPLATES
# include <sprout/math/constants.hpp> # include <sprout/math/constants.hpp>
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES #endif // #if SPROUT_USE_VARIABLE_TEMPLATES
namespace sprout { namespace sprout {
namespace math {
#if SPROUT_USE_VARIABLE_TEMPLATES #if SPROUT_USE_VARIABLE_TEMPLATES
namespace math { //
// // pi
// pi //
// template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T pi_v = sprout::math::pi<T>();
SPROUT_STATIC_CONSTEXPR T pi_v = sprout::math::pi<T>(); //
// // half_pi
// half_pi //
// template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T half_pi_v = sprout::math::half_pi<T>();
SPROUT_STATIC_CONSTEXPR T half_pi_v = sprout::math::half_pi<T>(); //
// // third_pi
// third_pi // two_thirds_pi
// two_thirds_pi //
// template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T third_pi_v = sprout::math::third_pi<T>();
SPROUT_STATIC_CONSTEXPR T third_pi_v = sprout::math::third_pi<T>(); template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T two_thirds_pi_v = sprout::math::two_thirds_pi<T>();
SPROUT_STATIC_CONSTEXPR T two_thirds_pi_v = sprout::math::two_thirds_pi<T>(); //
// // quarter_pi
// quarter_pi // three_quarters_pi
// three_quarters_pi //
// template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T quarter_pi_v = sprout::math::quarter_pi<T>();
SPROUT_STATIC_CONSTEXPR T quarter_pi_v = sprout::math::quarter_pi<T>(); template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T three_quarters_pi_v = sprout::math::three_quarters_pi<T>();
SPROUT_STATIC_CONSTEXPR T three_quarters_pi_v = sprout::math::three_quarters_pi<T>(); //
// // two_pi
// two_pi // four_pi
// four_pi //
// template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T two_pi_v = sprout::math::two_pi<T>();
SPROUT_STATIC_CONSTEXPR T two_pi_v = sprout::math::two_pi<T>(); template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T four_pi_v = sprout::math::four_pi<T>();
SPROUT_STATIC_CONSTEXPR T four_pi_v = sprout::math::four_pi<T>(); //
// // two_div_pi
// two_div_pi // root_two_div_pi
// root_two_div_pi //
// template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T two_div_pi_v = sprout::math::two_div_pi<T>();
SPROUT_STATIC_CONSTEXPR T two_div_pi_v = sprout::math::two_div_pi<T>(); template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T root_two_div_pi_v = sprout::math::root_two_div_pi<T>();
SPROUT_STATIC_CONSTEXPR T root_two_div_pi_v = sprout::math::root_two_div_pi<T>(); //
// // root_pi
// root_pi // one_div_root_pi
// one_div_root_pi // root_one_div_pi
// root_one_div_pi // two_div_root_pi
// two_div_root_pi //
// template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T root_pi_v = sprout::math::root_pi<T>();
SPROUT_STATIC_CONSTEXPR T root_pi_v = sprout::math::root_pi<T>(); template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T one_div_root_pi_v = sprout::math::one_div_root_pi<T>();
SPROUT_STATIC_CONSTEXPR T one_div_root_pi_v = sprout::math::one_div_root_pi<T>(); template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T root_one_div_pi_v = sprout::math::root_one_div_pi<T>();
SPROUT_STATIC_CONSTEXPR T root_one_div_pi_v = sprout::math::root_one_div_pi<T>(); template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T two_div_root_pi_v = sprout::math::two_div_root_pi<T>();
SPROUT_STATIC_CONSTEXPR T two_div_root_pi_v = sprout::math::two_div_root_pi<T>(); //
// // half
// half // quarter
// quarter // third
// third // two_thirds
// two_thirds //
// template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T half_v = sprout::math::half<T>();
SPROUT_STATIC_CONSTEXPR T half_v = sprout::math::half<T>(); template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T quarter_v = sprout::math::quarter<T>();
SPROUT_STATIC_CONSTEXPR T quarter_v = sprout::math::quarter<T>(); template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T third_v = sprout::math::third<T>();
SPROUT_STATIC_CONSTEXPR T third_v = sprout::math::third<T>(); template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T two_thirds_v = sprout::math::two_thirds<T>();
SPROUT_STATIC_CONSTEXPR T two_thirds_v = sprout::math::two_thirds<T>(); //
// // root_two
// root_two // root_three
// root_three // half_root_two
// half_root_two //
// template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T root_two_v = sprout::math::root_two<T>();
SPROUT_STATIC_CONSTEXPR T root_two_v = sprout::math::root_two<T>(); template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T root_three_v = sprout::math::root_three<T>();
SPROUT_STATIC_CONSTEXPR T root_three_v = sprout::math::root_three<T>(); template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T half_root_two_v = sprout::math::half_root_two<T>();
SPROUT_STATIC_CONSTEXPR T half_root_two_v = sprout::math::half_root_two<T>(); //
// // e
// e //
// template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T e_v = sprout::math::e<T>();
SPROUT_STATIC_CONSTEXPR T e_v = sprout::math::e<T>(); //
// // ln_ten
// ln_ten // ln_two
// ln_two //
// template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T ln_ten_v = sprout::math::ln_ten<T>();
SPROUT_STATIC_CONSTEXPR T ln_ten_v = sprout::math::ln_ten<T>(); template<typename T>
template<typename T> SPROUT_STATIC_CONSTEXPR T ln_two_v = sprout::math::ln_two<T>();
SPROUT_STATIC_CONSTEXPR T ln_two_v = sprout::math::ln_two<T>(); //
} // namespace math // phi
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES //
} // namespace sprout template<typename T>
SPROUT_STATIC_CONSTEXPR T phi_v = sprout::math::phi<T>();
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace math
} // namespace sprout
#endif // #ifndef SPROUT_MATH_CONSTANT_VARIABLES_HPP #endif // #ifndef SPROUT_MATH_CONSTANT_VARIABLES_HPP

View file

@ -154,6 +154,13 @@ namespace sprout {
inline SPROUT_CONSTEXPR T ln_two() { inline SPROUT_CONSTEXPR T ln_two() {
return static_cast<T>(0.693147180559945309417232121458176568075500134360255254120680009493393621969694715605863326996418687542001481021L); return static_cast<T>(0.693147180559945309417232121458176568075500134360255254120680009493393621969694715605863326996418687542001481021L);
} }
//
// phi
//
template<typename T>
inline SPROUT_CONSTEXPR T phi() {
return static_cast<T>(1.61803398874989484820458683436563811772030917980576286213544862270526046281890244970720720418939113748475408807L);
}
} // namespace math } // namespace math
} // namespace sprout } // namespace sprout