function pcubic_test ( )

%*****************************************************************************80
%
%MATLAB version of the FORTRAN program for Example 6.16 on page 291 of
% conte/deboor
% cubic spline interpolation to given data
%
%  Reference:
%
%    Samuel Conte, Carl de Boor,
%    Elementary Numerical Analysis,
%    Third Edition,
%    SIAM, 2017,
%    ISBN: 978-1-611975-19-2.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'pcubic_test\n' );
  fprintf ( 1, '  Test pcubic()\n' );

  XI = [0 1:5 6.1 6.1:.2:6.7 7:9 12:2:18];  % data taken from Fig.6.10
  C = [2.51 3.3 4.04 4.7 5.22 5.54 5.8 ...
             5.8 5.55 5.44 5.4 5.4 5.57 5.7 5.84 5.75 5.48 4.9;
     .8    0   0    0   0    0   .2 ...
             -1.8 0    0    0   0  0   0    0    0   0   -.35];
  N1 = 7; 

  NN = 1:N1;              
  sp1 = calccf ( XI(NN),spline_cd(XI(NN),C(:,NN)) );
  NN = N1+1:length(XI)  ; 
  sp2 = calccf ( XI(NN),spline_cd(XI(NN),C(:,NN)) );

  pc = struct ( 'breaks', XI([1:7,9:end]), 'coefs', [sp1.coefs sp2.coefs] );

  XX = XI(1):.5:20;
  SX = pcubic ( pc, XX );
  fprintf('  %10.3g   %10.3g  \n', [XX;SX])

  plot(XX,SX,'.');
  hold ( 'on' ); 
  plot(XI,C(1,:),'o');
  axis equal;
  hold ( 'off' )
  filename = 'pcubic_test.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end

