X-Git-Url: http://gitweb.michael.orlitzky.com/?p=octave.git;a=blobdiff_plain;f=advection_matrix_sparse.m;h=dea3e77fb0531d019e901fcde58f9317300a51d2;hp=a89536cbd11859212464d840f6e369e418418d61;hb=602624313348cec0073320c36849e16aba12b4cf;hpb=ee2abb133ffec1ba0a9177cb290738ce7a188dcf diff --git a/advection_matrix_sparse.m b/advection_matrix_sparse.m index a89536c..dea3e77 100644 --- a/advection_matrix_sparse.m +++ b/advection_matrix_sparse.m @@ -1,29 +1,29 @@ function S = advection_matrix_sparse(integerN) - ## - ## Sparse version of the advection_matrix function. See - ## advection_matrix.m for details. - ## + % + % Sparse version of the advection_matrix function. See + % advection_matrix.m for details. + % if (integerN < 2) S = NA; return end - ## The ones directly above the diagonal. + % The 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. S = top + bottom; - ## Fill in the entries in the corner. + % Fill in the entries in the corner. S(1, integerN) = -1; S(integerN, 1) = 1; - ## And divide the whole thing by 2. + % And divide the whole thing by 2. S = (1/2)*S; end