/[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 5707 - (show annotations)
Mon Jun 29 03:59:06 2015 UTC (3 years, 6 months ago) by sshaw
File MIME type: text/x-python
File size: 1021 byte(s)
adding copyright headers to files without copyright info, moved header to top of file in some cases where it wasn't
1
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2015 by The University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Open Software License version 3.0
9 # http://www.opensource.org/licenses/osl-3.0.php
10 #
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 from __future__ import print_function, division
18
19 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