~logan/ubuntu/trusty/suitesparse/4.2.1-3ubuntu1

« back to all changes in this revision

Viewing changes to CXSparse/MATLAB/Demo/private/mesh3d1.m

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2007-05-29 09:36:29 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070529093629-zowquo0b7slkk6nc
Tags: 3.0.0-2
* suitesparse builds properly twice in a row
* Bug fix: "suitesparse - FTBFS: Broken build depens: libgfortran1-dev",
  thanks to Bastian Blank (Closes: #426349).
* Bug fix: "suitesparse_3.0.0-1: FTBFS: build-depends on
  libgfortran1-dev", thanks to Steve Langasek (Closes: #426354).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function [A, keep, ii, jj, xx] = mesh3d1 (n)
 
2
% create an n-by-n-by-n 3D mesh for the 2nd difference operator
 
3
% Example:
 
4
%   A = mesh3d1 (10) ;  % a 10-by-10-by-10 mesh
 
5
% See also: cs_demo
 
6
 
 
7
%   Copyright 2006-2007, Timothy A. Davis.
 
8
%   http://www.cise.ufl.edu/research/sparse
 
9
 
 
10
ii = zeros (7*n^3, 1) ;
 
11
jj = zeros (7*n^3, 1) ;
 
12
xx = zeros (7*n^3, 1) ;
 
13
t = 1 ;
 
14
for k = 0:n-1
 
15
    for j = 0:n-1
 
16
        for i = 0:n-1
 
17
            s = k*n^2 + j*n+i + 1 ;
 
18
            ii (t:t+6) = [
 
19
                    (k-1)*n^2 + j*n+i 
 
20
                    k*n^2 + (j-1)*n+i 
 
21
                    k*n^2 + j*n+(i-1)
 
22
                    k*n^2 + j*n+i
 
23
                    k*n^2 + j*n+(i+1)
 
24
                    k*n^2 + (j+1)*n+i
 
25
                    (k+1)*n^2 + j*n+i ]' + 1 ;
 
26
            jj (t:t+6) = [s s s s s s s] ;
 
27
            xx (t:t+6) = [-1 -1 -1 6 -1 -1 -1] ;
 
28
            t = t + 7 ;
 
29
        end
 
30
    end
 
31
end
 
32
keep = find (ii >= 1 & ii <= n^3 & jj >= 1 & jj <= n^3) ;
 
33
A = sparse (ii (keep), jj (keep), xx (keep)) ;