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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6112 - (hide annotations)
Thu Mar 31 09:40:10 2016 UTC (4 years, 3 months ago) by jfenwick
File MIME type: text/x-python
File size: 1011 byte(s)
Relicense all the things!


1 sshaw 5706
2 sshaw 5707 ##############################################################################
3     #
4 jfenwick 5863 # Copyright (c) 2003-2016 by The University of Queensland
5 sshaw 5707 # http://www.uq.edu.au
6     #
7     # Primary Business: Queensland, Australia
8 jfenwick 6112 # Licensed under the Apache License, version 2.0
9     # http://www.apache.org/licenses/LICENSE-2.0
10 sshaw 5707 #
11     # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12     # Development 2012-2013 by School of Earth Sciences
13     # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14     #
15     ##############################################################################
16    
17 sshaw 5706 from __future__ import print_function, division
18    
19 caltinay 4955 from scipy.sparse import coo_matrix
20     from scipy.io import mmwrite
21     from numpy.random import permutation
22     M = N = 10
23    
24     for nnz in [0, 1, 2, 5, 8, 10, 15, 20, 30, 50, 80, 100]:
25     P = permutation(M * N)[:nnz]
26     I = P / N
27     J = P % N
28     V = permutation(nnz) + 1
29    
30     A = coo_matrix( (V,(I,J)) , shape=(M,N))
31     filename = '%03d_nonzeros.mtx' % (nnz,)
32     mmwrite(filename, A)
33    

  ViewVC Help
Powered by ViewVC 1.1.26