]> gitweb.factorcode.org Git - factor.git/commitdiff
Fixes complex shuffle words, Fixes complex array instantiation
authorinivekin <inivekin@gmail.com>
Sat, 20 Mar 2021 03:58:32 +0000 (11:58 +0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sat, 20 Mar 2021 04:08:40 +0000 (21:08 -0700)
extra/math/runge-kutta/examples/examples.factor
extra/math/runge-kutta/runge-kutta.factor

index b79c559d44ea80484ac3af6628319de0894261ab..715263e30606acb78764536e133bc8797587b737 100644 (file)
@@ -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 * + * ;
 
 :: <rabinovich-fabrikant> ( gamma alpha -- dx..n/dt delta tx..n t-limit )
     gamma '[ _ rf-dx/dt ] gamma '[ _ rf-dy/dt ] alpha '[ _ rf-dz/dt ]
index 77b0cda6dcbf9b4d4de929bd84b924a037e1c9ab..75b08b12a9622c12fb88f11cb2a772150287df43 100755 (executable)
@@ -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 <repetition> >array
+        dup first length>> 0 <array>
 
         ! reduce the results to the estimated change for the timestep
         [ v+ ] reduce