function A = matrix_assemble_parfor ( m, n )

%*****************************************************************************80
%
%% matrix_assemble_parfor() assembles the Hilbert matrix by columns.
%
%  Discussion:
%
%    For some reason, parfor() is extremely, extremely picky about how it
%    is willing to deal with indexed arrays.  Getting this example to work
%    involved many blind experiments and guesses, and I still can't
%    explain why exactly this code works, but seemingly equivalent formulations
%    will be rejected by parfor() with complaints such as "the variable
%    a cannot be classified".
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    22 May 2012
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer m, n: the number of rows and columns in the matrix.
%
%  Output:
%
%    real A(m,n): the Hilbert matrix.
%
  A = zeros ( m, n );
%
%  Setting the range K outside the loop seems to be crucial
%  to having parfor be willing to execute it!
%
  k = 1:n;

  parfor i = 1 : m
    
    A(i,k) = 1.0 ./ ( i + k );

  end

  return
end
