function paraheat_pwc_sample ( )

%*****************************************************************************80
%
%% paraheat_pwc_sample samples solutions from paraheat_pwc.
%
%  Discussion:
%
%    This program uses a random number seed to choose parameters 
%    vc as input to the paraheat_pwc() program, and 
%    saves the resulting sensor measurements ns, xs, ys, vs.
%
%    By repeatedly changing this seed, a set of samples of the data
%    are constructed.  
%
%    The sets of data (seed, vc, vs ) are written to a file.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    30 April 2019
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../paraheat_pwc' );

  timestamp ( );
  fprintf ( 1, 'paraheat_pwc_sample\n' );
  fprintf ( 1, '  Sample solutions computed by paraheat_pwc()\n' );
  fprintf ( 1, '  which accepts piecewise constant diffusivity parameters as input,\n' );
  fprintf ( 1, '  solves a certain steady heat equation problem\n' );
  fprintf ( 1, '  and returns the solution value at selected locations.\n' );

  sample_num = 5;
  diffusivity_seed = 123456789;
  nxc = 4;
  nyc = 4;
  ns = 50;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Generating %d random diffusivity cases.\n', sample_num );
  fprintf ( 1, '  The initial random number seed is %d\n', diffusivity_seed );
  fprintf ( 1, '  Each case involves:\n' );
  fprintf ( 1, '    1 diffusivity seed,\n' );
  fprintf ( 1, '    %d diffusivity parameters,\n', nxc * nyc );
  fprintf ( 1, '    %d sensor readings.\n', ns );

  data = zeros ( sample_num, 1 + nxc * nyc + ns );

  for i = 1 : sample_num

    rng ( diffusivity_seed );
    fprintf ( 1, '\n' );
    fprintf ( 1, '  Case %d, diffusivity_seed = %d\n', i, diffusivity_seed );

    vc = 0.5 + 5.0 * rand ( nxc, nyc );

    [ ns, xs, ys, vs ] = paraheat_pwc ( vc );

    vc = reshape ( vc, 1, nxc * nyc );
    vs = reshape ( vs, 1, ns );
    data(i,:) = [ diffusivity_seed, vc, vs ];

    diffusivity_seed = diffusivity_seed + 1;

  end
%
%  Write (seed,vc,vs) data to a file.
%
  filename = 'paraheat_pwc_sample_data.txt';
  save ( filename, 'data', '-ascii' );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  %d by %d array of data written to "%s"\n', ...
    sample_num, 1 + nxc * nyc + ns, filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'paraheat_pwc_sample\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  timestamp ( );

  rmpath ( '../paraheat_pwc' );

  return
end
function [ xmin, xmax, ymin, ymax ] = region_box ( )

%*****************************************************************************80
%
%% region_box returns the minimum and maximum x and y values of the region.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    10 April 2019
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Output, real XMIN, XMAX, YMIN, YMAX, the argument ranges.
%
  xmin = 0.0;
  xmax = 1.0;
  ymin = 0.0;
  ymax = 1.0;

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% TIMESTAMP prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end
