%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                                     %%
%%             Sum the Green's functions               %%
%%      for the one-dimensional Poisson equation       %%
%%                                                     %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function u_vals = gf1d_sumgf(x_vals,xi_vals,str_vals,n_max)

% initialize the sum to zero times the x-values
u_vals=0.0*x_vals;

% add the individual Green's functions one by one
for n=1:n_max
  u_vals=u_vals+0.5*abs(x_vals-xi_vals(n))*str_vals(n);
end
