basis/math: add logn to math.functions (fix #1981)
parent
89fa8e09ee
commit
4c96c9343c
|
@ -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" } "." } ;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 )
|
||||
|
|
Loading…
Reference in New Issue