
192 Introduction to Computational Linear Algebra
nnz gives the number of non-zero coefficients. Algorithm 7.5 generates
the non-zero coefficients of A.
Algorithm 7.5 Sparse Finite Difference Two-Dimensional Poisson Matrix
function [I,J,s,IB,UNK,f,U]=coeffa(pih,pik)
% UNK is the set of indices corresponding to the unknowns
% IB is the set of border indices
% J in IB: there exists an interior node such that s(I,J)~=0
% Pt is the coeffa table pointer. It is initialized to 0
UNK=[];IB=[];Pt=0;m=length(pih);n=length(pik);
[xs,ys,is,js,id,a,f,U]= Nodes(pih,pik);
%Computing the vector H={hi, i=1, ...,m-1}
% and K={kj, j=1, ...,n-1}
H=diff(pih);h=max(pih);K=diff(pik);h=max(pik); ...