/usr/share/pyshared/SparsExamples/matmul_perftest.py is in python-sparse-examples 1.1-1.3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | import time
from pysparse import spmatrix
n = 1000000
# create 2 nxn tridiag matrices
A = spmatrix.ll_mat(n, n)
B = spmatrix.ll_mat(n, n)
for i in xrange(n):
A[i,i] = i
B[i,i] = i
if i > 0:
A[i,i-1] = 1
B[i,i-1] = 1
if i < n-1:
A[i,i+1] = 1
B[i,i-1] = 1
t1 = time.clock()
C = spmatrix.matrixmultiply(A, B)
t_mult = time.clock() - t1
print 'time for multiplying %dx%d matrices: %.2f sec' % (n, n, t_mult)
print C[:10,:10]
|