/[escript]/trunk/cusplibrary/testing/data/random_10x10/generator.py
ViewVC logotype

Contents of /trunk/cusplibrary/testing/data/random_10x10/generator.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5706 - (show annotations)
Mon Jun 29 03:41:36 2015 UTC (5 years ago) by sshaw
File MIME type: text/x-python
File size: 427 byte(s)
all python files now force use of python3 prints and division syntax to stop sneaky errors appearing in py3 environs
1
2 from __future__ import print_function, division
3
4 from scipy.sparse import coo_matrix
5 from scipy.io import mmwrite
6 from numpy.random import permutation
7 M = N = 10
8
9 for nnz in [0, 1, 2, 5, 8, 10, 15, 20, 30, 50, 80, 100]:
10 P = permutation(M * N)[:nnz]
11 I = P / N
12 J = P % N
13 V = permutation(nnz) + 1
14
15 A = coo_matrix( (V,(I,J)) , shape=(M,N))
16 filename = '%03d_nonzeros.mtx' % (nnz,)
17 mmwrite(filename, A)
18

  ViewVC Help
Powered by ViewVC 1.1.26