function value = index4_col ( i1_min, i1, i1_max, i2_min, i2, i2_max, ...
  i3_min, i3, i3_max, i4_min, i4, i4_max, index_min )

%*****************************************************************************80
%
%% INDEX4_COL indexes a 4D array by columns.
%
%  Discussion:
%
%    Entries of the array are indexed starting at (I1_MIN,I2_MIN,I3_MIN,I4_MIN),
%    and increasing the initial index first, then the second, third and so on.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 April 2010
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer I1_MIN, I1, I1_MAX, for index 1,
%    the minimum, the index, and the maximum.
%
%    integer I2_MIN, I2, I2_MAX, for index 2,
%    the minimum, the index, and the maximum.
%
%    integer I3_MIN, I3, I3_MAX, for index 3,
%    the minimum, the index, and the maximum.
%
%    integer I4_MIN, I4, I4_MAX, for index 4,
%    the minimum, the index, and the maximum.
%
%    integer INDEX_MIN, the index of
%    (I1_MIN,I2_MIN,I3_MIN,I4_MIN).  Typically, this is 0 or 1.
%
%  Output:
%
%    integer VALUE, the index of element (I1,I2,I3,I4).
%
  value = index_min ...
    + ( i1 - i1_min ) ...
    + ( i2 - i2_min ) * ( i1_max + 1 - i1_min ) ...
    + ( i3 - i3_min ) * ( i2_max + 1 - i2_min ) * ( i1_max + 1 - i1_min ) ...
    + ( i4 - i4_min ) * ( i3_max + 1 - i3_min ) * ( i2_max + 1 - i2_min ) ...
    * ( i1_max + 1 - i1_min );

  return
end
