function L = laplacian5_torus_vector ( A, dx, dy )

%*****************************************************************************80
%
%% laplacian5_torus_vector uses a 5 point Laplacian stencil on a torus.
%
%  Discussion:
%
%    1) Assumes the region is a rectangular torus;
%    2) Assumes the mesh is uniform in both X and Y directions.
%    3) Assumes the spacing is dx in both directions.
%
%    Vectorized MATLAB statements are used for efficiency.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 June 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real A(NXP,NYP): function values, sampled on a regular grid.
%
%    real DX, DY: the grid spacing in the X and Y directions.
%
%  Output:
%
%    real L(NXP,NYP): the values of the Laplacian, as estimated by the
%    5 point periodic stencil.
%
  f_xx = (        circshift ( A, [  1,  0 ] ) ... 
         - 2.0 .* circshift ( A, [  0,  0 ] ) ...
                + circshift ( A, [ -1,  0 ] ) ) / dx^2;

  f_yy = (        circshift ( A, [  0,  1 ] ) ...
         - 2.0 .* circshift ( A, [  0,  0 ] ) ...
                + circshift ( A, [  0, -1 ] ) ) / dy^2;

  L = f_xx + f_yy;

  return
end

