add sprout::cbrt, hypot, fmax, fmin, fdim

fix sprout::pow case x==0
This commit is contained in:
bolero-MURAKAMI 2012-05-05 18:50:17 +09:00
parent feba220da4
commit 6ccd6e1cf4
10 changed files with 273 additions and 17 deletions

View file

@ -7,35 +7,46 @@ namespace sprout {
namespace math {
//
// pi
// half_pi
// quarter_pi
//
template<typename T>
inline SPROUT_CONSTEXPR T pi() {
return 3.141592653589793238462643383279502884197169399375105820974944L;
}
//
// half_pi
//
template<typename T>
inline SPROUT_CONSTEXPR T half_pi() {
return 1.570796326794896619231321691639751442098584699687552910487472L;
}
//
// quarter_pi
//
template<typename T>
inline SPROUT_CONSTEXPR T quarter_pi() {
return 0.785398163397448309615660845819875721049292349843776455243736L;
}
//
// half
// third
// twothirds
//
template<typename T>
inline SPROUT_CONSTEXPR T half() {
return 0.5L;
}
template<typename T>
inline SPROUT_CONSTEXPR T third() {
return 0.3333333333333333333333333333333333333333333333333333333333333333333333L;
}
template<typename T>
inline SPROUT_CONSTEXPR T twothirds() {
return 0.6666666666666666666666666666666666666666666666666666666666666666666666L;
}
//
// root_two
// half_root_two
//
template<typename T>
inline SPROUT_CONSTEXPR T root_two() {
return 1.414213562373095048801688724209698078569671875376948073L;
}
//
// half_root_two
//
template<typename T>
inline SPROUT_CONSTEXPR T half_root_two() {
return 0.70710678118654752440084436210484903928483593756084L;
@ -49,14 +60,12 @@ namespace sprout {
}
//
// ln_ten
// ln_two
//
template<typename T>
inline SPROUT_CONSTEXPR T ln_ten() {
return 2.302585092994045684017991454684364207601101488628772976L;
}
//
// ln_two
//
template<typename T>
inline SPROUT_CONSTEXPR T ln_two() {
return 0.693147180559945309417232121458176568075500134360255254L;