~ubuntu-branches/ubuntu/saucy/python-scipy/saucy

« back to all changes in this revision

Viewing changes to Lib/sandbox/pysparse/examples/matmul_perftest.py

  • Committer: Bazaar Package Importer
  • Author(s): Ondrej Certik
  • Date: 2008-06-16 22:58:01 UTC
  • mfrom: (2.1.24 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080616225801-irdhrpcwiocfbcmt
Tags: 0.6.0-12
* The description updated to match the current SciPy (Closes: #489149).
* Standards-Version bumped to 3.8.0 (no action needed)
* Build-Depends: netcdf-dev changed to libnetcdf-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import time
2
 
import spmatrix
3
 
 
4
 
 
5
 
n = 1000000
6
 
 
7
 
# create 2 nxn tridiag matrices
8
 
A = spmatrix.ll_mat(n, n)
9
 
B = spmatrix.ll_mat(n, n)
10
 
 
11
 
for i in xrange(n):
12
 
    A[i,i] = i
13
 
    B[i,i] = i
14
 
    if i > 0:
15
 
        A[i,i-1] = 1
16
 
        B[i,i-1] = 1
17
 
    if i < n-1:
18
 
        A[i,i+1] = 1
19
 
        B[i,i-1] = 1
20
 
 
21
 
 
22
 
t1 = time.clock()
23
 
C = spmatrix.matrixmultiply(A, B)
24
 
t_mult = time.clock() - t1
25
 
print 'time for multiplying %dx%d matrices: %.2f sec' % (n, n, t_mult)
26
 
print C[:10,:10]