function i4mat = i4rows_to_i4mat ( m, n, i4rows )

%*****************************************************************************80
%
%% I4ROWS_TO_I4MAT converts a row-major vector to an I4MAT.
%
%  Discussion:
%
%    An I4MAT is an MxN array of I4's, in column major order.
%
%    I am frustrated that the FORTRAN standard for initializing an array
%    forces me to enter a table of data by columns, so that I have to
%    transpose the information, which is confusing to me and any reader.
%
%    This function allows me to declare a vector of the right type and length,
%    fill it with data that I can display row-wise, and then have the
%    data copied into a column-major doubly-indexed array.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 September 2018
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, N, the number of rows and columns.
%
%    integer I4ROWS(M*N), the data, stored rowwise
%    in a vector.
%
%  Output:
%
%    integer I4MAT(M,N), a copy of the data, stored
%    columnwise in an array.
%
  k = 0;
  i4mat = zeros ( m, n );
  for i = 1 : m
    for j = 1 : n
      k = k + 1;
      i4mat(i,j) = i4rows(k);
    end
  end

  return
end
