File: ex3.m

package info (click to toggle)
suitesparse 1%3A7.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 254,920 kB
  • sloc: ansic: 1,134,743; cpp: 46,133; makefile: 4,875; fortran: 2,087; java: 1,826; sh: 996; ruby: 725; python: 495; asm: 371; sed: 166; awk: 44
file content (42 lines) | stat: -rw-r--r-- 934 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
function ex3
%EX3: create 2D and 3D meshes using mesh2d1, mesh2d2, mesh3d1, mesh3d2.

% Example:
%   ex3
% See also: cs_demo

% CXSparse, Copyright (c) 2006-2022, Timothy A. Davis. All Rights Reserved.
% SPDX-License-Identifier: LGPL-2.1+

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