Merge branch 'master' of git://factorcode.org/git/factor

db4
Slava Pestov 2009-09-11 21:03:46 -05:00
commit a86a9c99f7
4 changed files with 17 additions and 3 deletions

View File

@ -1,7 +1,7 @@
! Copyright (C) 2008 Peter Burns, 2009 Philipp Winkler
! See http://factorcode.org/license.txt for BSD license.
USING: arrays assocs combinators io io.streams.string json
kernel math math.parser math.parser.private prettyprint
kernel math math.parser prettyprint
sequences strings vectors ;
IN: json.reader
@ -100,4 +100,4 @@ DEFER: j-string
PRIVATE>
: json> ( string -- object )
(json-parser>) ;
(json-parser>) ;

View File

@ -51,6 +51,7 @@ ARTICLE: "power-functions" "Powers and logarithms"
{ $subsection exp }
{ $subsection cis }
{ $subsection log }
{ $subsection log1+ }
{ $subsection log10 }
"Raising a number to a power:"
{ $subsection ^ }
@ -125,6 +126,10 @@ HELP: log
{ $values { "x" number } { "y" number } }
{ $description "Natural logarithm function. Outputs negative infinity if " { $snippet "x" } " is 0." } ;
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" } "." } ;
HELP: log10
{ $values { "x" number } { "y" number } }
{ $description "Logarithm function base 10. Outputs negative infinity if " { $snippet "x" } " is 0." } ;

View File

@ -163,7 +163,13 @@ M: float log dup 0.0 >= [ flog ] [ 0.0 rect> log ] if ; inline
M: real log >float log ; inline
M: complex log >polar swap flog swap rect> ; inline
M: complex log >polar [ flog ] dip rect> ; inline
GENERIC: log1+ ( x -- y )
M: object log1+ 1 + log ; inline
M: float log1+ dup -1.0 >= [ flog1+ ] [ 1.0 + 0.0 rect> log ] if ; inline
: 10^ ( x -- y ) 10 swap ^ ; inline

View File

@ -46,6 +46,9 @@ IN: math.libm
"double" "libm" "sqrt" { "double" } alien-invoke ;
! Windows doesn't have these...
: flog1+ ( x -- y )
"double" "libm" "log1p" { "double" } alien-invoke ;
: facosh ( x -- y )
"double" "libm" "acosh" { "double" } alien-invoke ;