
function r8mat_det_test ( )

%*****************************************************************************80
%
%% R8MAT_DET_TEST tests R8MAT_DET.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    16 June 2015
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'R8MAT_DET_TEST\n' );
  fprintf ( 1, '  R8MAT_DET: determinant of a real matrix.\n' );
  fprintf ( 1, '\n' );
 
  n = 3;
  a = zeros ( n, n );

  k = 0;
  for i = 1 : n
    for j = 1 : n
      k = k + 1;
      a(i,j) = k;
    end
  end
 
  r8mat_print ( n, n, a, '  The 123/456/789 matrix:' );

  det = r8mat_det ( n, a );
 
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Determinant of the 123/456/789 matrix is %g\n', det );
 
  n = 4;
  a = zeros ( n, n );

  for i = 1 : n
    for j = 1 : n
      a(i,j) = 1.0 / ( i + j );
    end
  end
 
  r8mat_print ( n, n, a, '  The Hilbert matrix:' );

  det = r8mat_det ( n, a );
 
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Determinant of the Hilbert matrix is %g\n', det );
 
  n = 3;
  a = zeros ( n, n );

  for i = 1 : n
    for j = 1 : n
      if ( i == j )
        a(i,j) = 2.0;
      elseif ( i == j + 1 || i == j - 1 )
        a(i,j) = -1.0;
      else
        a(i,j) = 0.0;
      end
    end
  end
 
  r8mat_print ( n, n, a, '  The -1,2,-1 matrix:' );

  det = r8mat_det ( n, a );
 
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Determinant of the -1,2,-1 matrix is %g\n', det );
 
  return
end
