Mercurial > matrix-functions
comparison toolbox/neumann.m @ 2:c124219d7bfa draft
Re-add the 1995 toolbox after noticing the statement in the ~higham/mctoolbox/ webpage.
author | Antonio Pino Robles <data.script93@gmail.com> |
---|---|
date | Thu, 07 May 2015 18:36:24 +0200 |
parents | 8f23314345f4 |
children |
comparison
equal
deleted
inserted
replaced
1:e471a92d17be | 2:c124219d7bfa |
---|---|
1 function [A, T] = neumann(n) | |
2 %NEUMANN Singular matrix from the discrete Neumann problem (sparse). | |
3 % NEUMANN(N) is the singular, row diagonally dominant matrix resulting | |
4 % from discretizing the Neumann problem with the usual five point | |
5 % operator on a regular mesh. | |
6 % It has a one-dimensional null space with null vector ONES(N,1). | |
7 % The dimension N should be a perfect square, or else a 2-vector, | |
8 % in which case the dimension of the matrix is N(1)*N(2). | |
9 | |
10 % Reference: | |
11 % R.J. Plemmons, Regular splittings and the discrete Neumann | |
12 % problem, Numer. Math., 25 (1976), pp. 153-161. | |
13 | |
14 if max(size(n)) == 1 | |
15 m = sqrt(n); | |
16 if m^2 ~= n, error('N must be a perfect square.'), end | |
17 n(1) = m; n(2) = m; | |
18 end | |
19 | |
20 T = tridiag(n(1), -1, 2, -1); | |
21 T(1,2) = -2; | |
22 T(n(1),n(1)-1) = -2; | |
23 | |
24 A = kron(T, eye(n(2))) + kron(eye(n(2)), T); |