1 function S = advection_matrix_sparse(integerN)
3 ## Sparse version of the advection_matrix function. See
4 ## advection_matrix.m for details.
12 ## The ones directly above the diagonal.
13 top = [ [zeros(integerN-1, 1), speye(integerN-1)]; ...
16 ## The negative ones directly below the diagonal.
17 bottom = [ [zeros(1, integerN-1); ...
18 -speye(integerN-1) ], zeros(integerN, 1)];
20 ## Combine the top and bottom.
23 ## Fill in the entries in the corner.
27 ## And divide the whole thing by 2.