1: % UFgetPetscMat.m
2: % modified from UFget_example.m
3: % This script
4: % (1) gets the selected index file of the UF sparse matrix collection,
5: % (2) loads in matrices in matlab format in increasing order of
6: % number of rows in the selected matrices,
7: % (3) writes into PETSc binary format in the given directory with
8: % each matrix named as A_{id}
9: %
10: % See also UFget_example.m
11: % Copyright 2009, PETSc Team.
13: index = UFget;
15: % sets selection here
16: f = find (index.nrows == index.ncols & index.nrows > 940000 & index.isReal) ;
17: [y, j] = sort (index.nrows (f)) ;
18: f = f (j) ;
20: for i = f
21: %loads in matrix in matlab format
22: %---------------------------------
23: fprintf ('Loading %s%s%s, please wait ...\n', ...
24: index.Group {i}, filesep, index.Name {i}) ;
25: Problem = UFget (i,index) ;
26: disp (Problem) ;
27: title (sprintf ('%s:%s', Problem.name, Problem.title')) ;
29: % convets to PETSc binary format and writes into ~mat/A_{id}
30: %-----------------------------------------------------------
31: fname = ['mat/A',num2str(i)];
32: fprintf ('write matrix into petsc binary file %s ...\n',fname);
33: PetscBinaryWrite(fname,Problem.A);
34: %input ('hit enter to continue:') ;
35: end