File: test7.m

package info (click to toggle)
suitesparse 1%3A5.12.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 176,720 kB
  • sloc: ansic: 1,193,914; cpp: 31,704; makefile: 6,638; fortran: 1,927; java: 1,826; csh: 765; ruby: 725; sh: 529; python: 333; perl: 225; sed: 164; awk: 35
file content (63 lines) | stat: -rw-r--r-- 1,127 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function test7
%TEST7 test sparse2
% Example:
%   test7
% See also cholmod_test

% Copyright 2007, Timothy A. Davis, http://www.suitesparse.com

fprintf ('=================================================================\n');
fprintf ('test7: test sparse2\n') ;

randn ('state', 0) ;
rand  ('state', 0) ;

% Prob = ssget (437)
Prob = ssget (750)							    %#ok
A = Prob.A ;
[m n] = size (A) ;

tic
[i j x] = find (A) ;
t = toc ;
fprintf ('find time %8.4f\n', t) ;

tic ;
B = sparse2 (i,j,x,m,n) ;						    %#ok
t1 = toc ;
fprintf ('tot: %8.6f\n', t1)

tic ;
B = sparse2 (i,j,x,m,n) ;						    %#ok
t1 = toc ;
fprintf ('tot: %8.6f again \n', t1) ;

tic ;
B1 = sparse2 (i,j,x) ;							    %#ok
t1 = toc ;
fprintf ('tot: %8.6f (i,j,x)\n', t1) ;

nz = length (x) ;
p = randperm (nz) ;

i2 = i(p) ;
j2 = j(p) ;
x2 = x(p) ;								    %#ok

tic ;
B = sparse2 (i,j,x,m,n) ;						    %#ok
t1 = toc ;

fprintf ('tot: %8.6f  (jumbled)\n', t1) ;

ii = [i2 ; i2] ;
jj = [j2 ; j2] ;
xx = rand (2*nz,1) ;

tic ;
D = sparse2 (ii,jj,xx,m,n) ;						    %#ok
t1 = toc ;

fprintf ('tot %8.6f  (duplicates)\n', t1) ;

fprintf ('test7 passed\n') ;