From: inivekin Date: Sat, 20 Mar 2021 03:58:32 +0000 (+0800) Subject: Fixes complex shuffle words, Fixes complex array instantiation X-Git-Tag: 0.99~2409 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=ce449104e9dd244fd3fca7cc84c5afc806b068f0 Fixes complex shuffle words, Fixes complex array instantiation --- diff --git a/extra/math/runge-kutta/examples/examples.factor b/extra/math/runge-kutta/examples/examples.factor index b79c559d44..715263e306 100644 --- a/extra/math/runge-kutta/examples/examples.factor +++ b/extra/math/runge-kutta/examples/examples.factor @@ -8,7 +8,7 @@ IN: math.runge-kutta.examples : lorenz-dy/dt ( tx..n -- dy ) rest first3 - 28 swap - [ swap ] dip * swap - ; + 28 swap - swapd * swap - ; : lorenz-dz/dt ( tx..n -- dz ) rest first3 @@ -36,7 +36,7 @@ IN: math.runge-kutta.examples :: rf-dz/dt ( tx..n alpha -- dz ) tx..n rest first3 :> ( x y z ) - 2 neg z * alpha x y * + * ; + -2 z * alpha x y * + * ; :: ( gamma alpha -- dx..n/dt delta tx..n t-limit ) gamma '[ _ rf-dx/dt ] gamma '[ _ rf-dy/dt ] alpha '[ _ rf-dz/dt ] diff --git a/extra/math/runge-kutta/runge-kutta.factor b/extra/math/runge-kutta/runge-kutta.factor index 77b0cda6dc..75b08b12a9 100755 --- a/extra/math/runge-kutta/runge-kutta.factor +++ b/extra/math/runge-kutta/runge-kutta.factor @@ -9,17 +9,17 @@ IN: math.runge-kutta runge-kutta-2-transform ; : runge-kutta-4-transform ( rk3 tx..n delta -- tx..n' delta ) - [ [ swap ] dip [ v*n ] keep prefix v+ ] keep ; + [ swapd [ v*n ] keep prefix v+ ] keep ; : (runge-kutta) ( delta tx..n dx..n/dt -- rk ) - [ swap ] dip dup length>> [ cleave ] dip narray swap v*n + swapd dup length>> [ cleave ] dip narray swap v*n ; inline : runge-kutta-differentials ( dx..n/dt -- seq ) '[ _ (runge-kutta) ] ; : runge-kutta-transforms ( tx..n delta dx..n/dt -- seq ) - -rot swap + spin [ { [ ] [ runge-kutta-2-transform ] [ runge-kutta-3-transform ] @@ -48,7 +48,7 @@ IN: math.runge-kutta call( -- rk1 rk2 rk3 rk4 rk4 ) drop 4array ! make array of zeroes of appropriate length to reduce into - dup first length>> 0 >array + dup first length>> 0 ! reduce the results to the estimated change for the timestep [ v+ ] reduce