basis/math: add logn to math.functions (fix #1981)

paths
Cat Stevens 2018-03-22 17:13:47 -04:00 committed by John Benediktsson
parent 89fa8e09ee
commit 4c96c9343c
3 changed files with 11 additions and 0 deletions

View File

@ -117,6 +117,10 @@ HELP: log
{ $values { "x" number } { "y" number } }
{ $description "Natural logarithm function. Outputs negative infinity if " { $snippet "x" } " is 0." } ;
HELP: logn
{ $values { "x" number } { "n" number } { "y" number } }
{ $description "Finds the base " { $snippet "n" } " logarithm of " { $snippet "x" } "." } ;
HELP: log1+
{ $values { "x" number } { "y" number } }
{ $description "Takes the natural logarithm of " { $snippet "1 + x" } ". Outputs negative infinity if " { $snippet "1 + x" } " is zero. This word may be more accurate than " { $snippet "1 + log" } " for very small values of " { $snippet "x" } "." } ;

View File

@ -69,6 +69,10 @@ IN: math.functions.tests
{ 0.0 } [ 1.0 log ] unit-test
{ 1.0 } [ e log ] unit-test
{ 0.0 } [ 1 e logn ] unit-test
{ 0.0 } [ 1.0 e logn ] unit-test
{ 1.0 } [ e e logn ] unit-test
CONSTANT: log-factorial-1000 0x1.71820d04e2eb6p12
CONSTANT: log10-factorial-1000 0x1.40f3593ed6f8ep11

View File

@ -196,6 +196,9 @@ M: real log >float log ; inline
M: complex log >polar [ flog ] dip rect> ; inline
: logn ( x n -- y )
[ log ] bi@ / ;
<PRIVATE
: most-negative-finite-float ( -- x )