function vp = diffusivity_1d_pwc ( nc, xc, vc, np, xp )

%*****************************************************************************80
%
%% DIFFUSIVITY_1D_PWC: piecewise constant diffusivity function in 1D.
%
%  Discussion:
%
%    A piecewise constant function is defined over NC intervals, 
%    with interval IC associated with constant value VC(I),
%    separated by NC-1 ascending sorted breakpoints.
%
%    The function is to be evaluated at NP points.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    23 March 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer NC, the number of function values.
%
%    real XC(NC-1), the breakpoints, in ascending order.
%
%    real VC(NC), the function values over each interval.
%
%    integer NP, the number of evaluation points.
%
%    real XP(NP), the evaluation points.
%
%  Output:
%
%    real VP(NP), the function value at the evaluation points.
%
  vp = zeros ( np, 1 );

  for ip = 1 : np
    kc = 1;
    for ic = 1 : nc - 1
      if ( xp(ip) < xc(ic) )
        break
      end
      kc = kc + 1;
    end
    vp(ip) = vc(kc);
  end

  return
end
