]> gitweb.factorcode.org Git - factor.git/blob - extra/benchmark/matrix-exponential-scalar/matrix-exponential-scalar.factor
core: Rename iota to <iota> so we can have TUPLE: iota ... ; instead of TUPLE: iota...
[factor.git] / extra / benchmark / matrix-exponential-scalar / matrix-exponential-scalar.factor
1 USING: locals math math.combinatorics math.matrices
2 prettyprint sequences typed ;
3 IN: benchmark.matrix-exponential-scalar
4
5 :: e^m ( m iterations -- e^m )
6     {
7         { 0.0 0.0 0.0 0.0 }
8         { 0.0 0.0 0.0 0.0 }
9         { 0.0 0.0 0.0 0.0 }
10         { 0.0 0.0 0.0 0.0 }
11     }
12     iterations <iota> [| i |
13         m i m^n i factorial >float m/n m+
14     ] each ;
15
16 :: matrix-exponential-scalar-benchmark ( -- )
17     f :> result!
18     4 identity-matrix :> i4
19     10000 [
20         i4 20 e^m result!
21     ] times
22     result . ;
23
24 MAIN: matrix-exponential-scalar-benchmark