Windows C runtime library doesn't have inverse hyperbolic functions

db4
U-SLAVA-DFB8FF805\Slava 2008-06-07 07:22:09 -05:00
parent 30b07346eb
commit 5bae4c6e89
3 changed files with 19 additions and 15 deletions

View File

@ -44,7 +44,10 @@ IN: math.functions.tests
[ t ] [ 10 asin sin 10 1.e-10 ~ ] unit-test
[ t ] [ -1 sqrt neg dup acos cos 1.e-10 ~ ] unit-test
[ t ] [ -100 atan tan -100 1.e-10 ~ ] unit-test
[ t ] [ 10 asinh sinh 10 1.e-10 ~ ] unit-test
[ t ] [ 10 atanh tanh 10 1.e-10 ~ ] unit-test
[ t ] [ 0.5 atanh tanh 0.5 1.e-10 ~ ] unit-test
[ 100 ] [ 100 100 gcd nip ] unit-test
[ 100 ] [ 1000 100 gcd nip ] unit-test

View File

@ -182,17 +182,17 @@ M: number (^)
: coth ( x -- y ) tanh recip ; inline
: acosh ( x -- y )
dup >=1? [ facosh ] [ dup sq 1- sqrt + log ] if ; inline
dup sq 1- sqrt + log ; inline
: asech ( x -- y ) recip acosh ; inline
: asinh ( x -- y )
dup complex? [ dup sq 1+ sqrt + log ] [ fasinh ] if ; inline
dup sq 1+ sqrt + log ; inline
: acosech ( x -- y ) recip asinh ; inline
: atanh ( x -- y )
dup [-1,1]? [ fatanh ] [ dup 1+ swap 1- neg / log 2 / ] if ; inline
dup 1+ swap 1- neg / log 2 / ; inline
: acoth ( x -- y ) recip atanh ; inline

25
extra/math/libm/libm.factor Normal file → Executable file
View File

@ -15,18 +15,6 @@ IN: math.libm
"double" "libm" "atan" { "double" } alien-invoke ;
foldable
: facosh ( x -- y )
"double" "libm" "acosh" { "double" } alien-invoke ;
foldable
: fasinh ( x -- y )
"double" "libm" "asinh" { "double" } alien-invoke ;
foldable
: fatanh ( x -- y )
"double" "libm" "atanh" { "double" } alien-invoke ;
foldable
: fatan2 ( x y -- z )
"double" "libm" "atan2" { "double" "double" } alien-invoke ;
foldable
@ -70,3 +58,16 @@ IN: math.libm
: fsqrt ( x -- y )
"double" "libm" "sqrt" { "double" } alien-invoke ;
foldable
! Windows doesn't have these...
: facosh ( x -- y )
"double" "libm" "acosh" { "double" } alien-invoke ;
foldable
: fasinh ( x -- y )
"double" "libm" "asinh" { "double" } alien-invoke ;
foldable
: fatanh ( x -- y )
"double" "libm" "atanh" { "double" } alien-invoke ;
foldable