X-Git-Url: http://gitweb.michael.orlitzky.com/?p=octave.git;a=blobdiff_plain;f=diffusion_matrix_sparse.m;h=600363c904bec4eefb8073c2bbc94f285ded8d51;hp=dbe4e2a53a0c4af68a0374f7782dd9c5b7baab85;hb=b12c6c2a4bf4cef29b2e08b743c92889505c7ed9;hpb=e1b71b4ca7cfa08ac76744a17a3778d4ccfaa7e2 diff --git a/diffusion_matrix_sparse.m b/diffusion_matrix_sparse.m index dbe4e2a..600363c 100644 --- a/diffusion_matrix_sparse.m +++ b/diffusion_matrix_sparse.m @@ -1,26 +1,26 @@ function K = diffusion_matrix_sparse(integerN) - ## - ## A sparse representation of the matrix K in the advection-diffusion - ## equation. See advection_matrix.m for details. - ## + % + % A sparse representation of the matrix K in the advection-diffusion + % equation. See advection_matrix.m for details. + % if (integerN < 2) K = NA; return end - ## The negative ones directly above the diagonal. + % The negative ones directly above the diagonal. top = [ [zeros(integerN-1, 1), -speye(integerN-1)]; ... zeros(1, integerN)]; - ## The negative ones directly below the diagonal. + % The negative ones directly below the diagonal. bottom = [ [zeros(1, integerN-1); ... -speye(integerN-1) ], zeros(integerN, 1)]; - ## Combine the top and bottom. + % Combine the top and bottom. K = top + bottom + 2*speye(integerN); - ## Fill in the entries in the corner. + % Fill in the entries in the corner. K(1, integerN) = -1; K(integerN, 1) = -1; end