function plasma_matrix_test01 ( n )

%*****************************************************************************80
%
%% plasma_matrix_test01() creates a plasma matrix and solves a linear system.
%
%  Discussion:
%
%    The use specifies a linear grid dimension of N, corresponding to N^2
%    grid points and N^4 matrix entries.  However, the actual matrix is
%    sparse, to only about 5*N^2 entries are nonzero.  
%
%    MATLAB sparse storage is used for the matrix.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    20 January 2014
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the linear order of the spatial grid.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'plasma_matrix_test01():\n' );
  fprintf ( 1, '  Linear order of spatial grid = %d\n', n );
  fprintf ( 1, '  Number of grid points is %d\n', n * n );
  fprintf ( 1, '  Approximate number of nonzero matrix entries is %d.\n', 5 * n * n );
  fprintf ( 1, '  Full storage matrix would require %d entries.\n', n^4 );

  [ A, b ] = plasma_matrix ( n );

  b_norm = norm ( b );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Norm of right hand side b is %g\n', b_norm )

  spy ( A );
  filename = sprintf ( 'plasma_%d_sparsity.png', n );
  print ( '-dpng', filename );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Sparsity image saved as "%s"\n', filename );
%
%  Solve the system A * x = - b.
%
  x = A \ ( - b );
  x_norm = norm ( x );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Norm of solution is %g\n', x_norm )

  return
end
