1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
| GNU Octave
----------
$ cat bigmult.m
s = 2000;
m = reshape(linspace(double(1.0),double(s*s),s*s),s,s);
n = max(abs(m*m)(:));
n
$ time octave -q bigmult.m
n = 1.6005e+16
real 0m4.847s
user 0m4.710s
sys 0m0.120s
hmatrix (Haskell)
-----------------
$ cat bigmult.hs
import Numeric.LinearAlgebra
main =
let m = (2000><2000) [1..] :: Matrix Double
m2 = m `multiply` m
n2 = normInf . flatten $ m2
in print n2
$ ghc --make -O2 bigmult.hs
$ time ./bigmult
1.6005333334e16
real 0m5.767s
user 0m5.470s
sys 0m0.280s
Python SciPy
------------
$ cat bigmult.py
from scipy import *
s = 2000
a = arange(1.0,s*s+1).reshape((s,s))
m = matrix(a)
print (abs(m*m)).max()
$ time python bigmult.py
1.6005333334e+16
real 1m18.862s
user 1m18.180s
sys 0m0.310s
|