move nth-root to math.functions, use exchange-unsafe in math.statistics

db4
Doug Coleman 2009-10-30 02:35:51 -05:00
parent 1cf45abf06
commit 003787113f
3 changed files with 6 additions and 8 deletions

View File

@ -106,6 +106,8 @@ PRIVATE>
[ ^complex ]
} cond ; inline
: nth-root ( n x -- y ) swap recip ^ ; inline
: gcd ( x y -- a d )
[ 0 1 ] 2dip (gcd) dup 0 < [ neg ] when ; foldable
@ -304,4 +306,3 @@ M: real atan >float atan ; inline
[ [ / floor ] [ * ] bi ] unless-zero ;
: lerp ( a b t -- a_t ) [ over - ] dip * + ; inline

View File

@ -1,8 +1,8 @@
! Copyright (C) 2008 Doug Coleman, Michael Judge.
! See http://factorcode.org/license.txt for BSD license.
USING: arrays combinators kernel math math.analysis
math.functions math.order sequences sorting locals
sequences.private assocs fry ;
USING: arrays combinators kernel math math.functions
math.order sequences sorting locals sequences.private
assocs fry ;
IN: math.statistics
: mean ( seq -- x )
@ -33,7 +33,7 @@ IN: math.statistics
[ i seq nth-unsafe x < ] [ i 1 + i! ] while
[ x j seq nth-unsafe < ] [ j 1 - j! ] while
i j <= [
i j seq exchange
i j seq exchange-unsafe
i 1 + i!
j 1 - j!
] when

View File

@ -56,9 +56,6 @@ PRIVATE>
[ abs gammaln-lanczos6 ] keep dup 0 > [ drop ] [ gamma-neg ] if
] if ;
: nth-root ( n x -- y )
swap recip ^ ;
! Forth Scientific Library Algorithm #1
!
! Evaluates the Real Exponential Integral,