function y=part_sum_c(a,b,t,A)
%PART_SUM_C evaluates the partial sum of a Fourier series with half-
%period = A and having ther coefficients a_0, a_1, a_2, ... , a_n 
%stored in the row a and the coefficients b_1, b_2, ... , b_n stored
%in the row b. The array t contains the points at which the partial 
%sum is to be evaluated. If all the a's are 0, except a_0, enter a=a_0.
%(This can be zero, too.) If all b's are zero, enter b=0. The output 
%array y contains the values of the partial sum at t.
%
%         F. J. Narcowich (1/21/03)
%         -- with modifications by Daniel Harding (2/11/02)
%

if (nargin == 3)
    A=pi;
end

a=a(:).'; % These are now row vectors.
b=b(:).';
if length(a)==1,
    a=[a,zeros(1,length(b))];
end

if b==0,
    b=zeros(1,length(a)-1);
end

if length(a)-length(b)~=1,
  error('The coefficient arrays have the wrong lengths.')
end

indx=1:length(b);
[C,S]=values(indx,t,A);
y=a*C+b*S;

function [C,S]=values(indx,eval_pts,A)
t=eval_pts;
C=[ones(1,length(t));cos((pi/A).*indx'*t)];
S=sin((pi/A).*indx'*t);
