function value = antithetic_memory ( i, value )

%*****************************************************************************80
%
%% ANTITHETIC_MEMORY stores the antithetic value for all generators.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    31 March 2013
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer I, the desired action.
%    -1, get a value.
%    0, initialize all values.
%    1, set a value.
%
%    Input/output, logical VALUE.  For I = -1, VALUE is an output
%    quantity, for I = +1, VALUE is an input quantity.
%
  persistent a_save;

  g_max = 32;

  if ( i < 0 )
    g = cgn_get ( );
    value = a_save(g);
  elseif ( i == 0 )
    a_save(1:g_max) = 0;
    value = 0;
  elseif ( 0 < i )
    g = cgn_get ( );
    a_save(g) = value;
  end

  return
end
