function tcs=tcsapi(x,y,z)
%TCSAPI	Bicubic spline interpolant.
%
%        tcs=tcsapi(x,y,z)
%
% returns the bicubic spline interpolant to the data z(i,j)=f(x(i),y(j)),
% using the knot-a-knot end conditions.

% Carl de Boor: Feb.4, 1991
% Copyright (c) 1990-92 by Carl de Boor and The MathWorks, Inc.

nx=length(x);ny=length(y);
if (nx < 4|ny < 4), 
   fprintf('tcsapi.m expects at least a 4 by 4 mesh.\n'),
   return
end
knotsx=augknt(x([1,3:(nx-2),nx]),4);
knotsy=augknt(y([1,3:(ny-2),ny]),4);

coefs=slvblk(spcol(knotsx,4,x,1),z)';
coefs=slvblk(spcol(knotsy,4,y,1),coefs)';

tcs=tspmak(knotsx,knotsy,coefs);
