File: ex3.m

package info (click to toggle)
suitesparse 1%3A3.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 40,788 kB
  • sloc: ansic: 106,134; cpp: 13,129; makefile: 6,679; fortran: 4,591; csh: 763; ruby: 603; perl: 236; sed: 164; awk: 29; sh: 8
file content (42 lines) | stat: -rw-r--r-- 908 bytes parent folder | download | duplicates (10)
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
function ex3
%EX3: create 2D and 3D meshes using mesh2d1, mesh2d2, mesh3d1, mesh3d2.

% Example:
%   ex3
% See also: cs_demo

%   Copyright 2006-2007, Timothy A. Davis.
%   http://www.cise.ufl.edu/research/sparse

t1 = zeros (50,1) ;
t2 = zeros (50,1) ;
t3 = zeros (50,1) ;
t4 = zeros (50,1) ;

fprintf ('run times for each method, given n:\n') ;
for n = 2:50

    tic ;
    A = mesh2d1 (n) ;
    t1 (n) = toc ;

    tic
    B = mesh2d2 (n) ;
    t2 (n) = toc ;

    tic
    C = mesh3d1 (n) ;
    t3 (n) = toc ;

    tic
    D = mesh3d2 (n) ;
    t4 (n) = toc ;

    fprintf ('%3d: %8.3f %8.3f %8.3f %8.3f\n', n, t1(n), t2(n), t3(n), t4(n)) ;

    subplot (2,2,1) ; spy (A) ; title ('2D mesh, method 1') ;
    subplot (2,2,2) ; spy (B) ; title ('2D mesh, method 2') ;
    subplot (2,2,3) ; spy (C) ; title ('3D mesh, method 1') ;
    subplot (2,2,4) ; spy (D) ; title ('3D mesh, method 2') ;
    drawnow
end