function Z = gaussian_2d ( c, X, Y, xmu, ymu, xsigma, ysigma, A )

%*****************************************************************************80
%
%% gaussian_2d() evaluates a Gaussian function of a 2D argument.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    18 February 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real C, the multiplier.
%
%    real X(M,N), Y(M,N), the evaluation points.
%
%    real XMU, YMU, the mean or center of the gaussian function.
%
%    real XSIGMA, YSIGMA, the variance.
%
%    real A(2,2), a positive definite matrix.
%
%  Output:
%
%    real Z(M,N), the value of the gaussian function.
%
  [ m, n ] = size ( X );

  x = reshape ( X, 1, m * n );
  y = reshape ( Y, 1, m * n );
%
%  Form an Nx2 array.
%
  v = [ ( x - xmu ) / xsigma; ( y - ymu ) / ysigma ];

  Av = A * v;

  vtAv = dot ( v, Av );

  z = c * exp ( - 0.5 * vtAv );

  Z = reshape ( z, m, n );

  return
end

