function linpack_bench_backslash ( n, lda )

%*****************************************************************************80
%
%% linpack_bench_backslash() drives the LINPACK benchmark program.
%
%  Discussion:
%
%    This version solves the system using the backslash operator.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    06 February 2025
%
%  Author:
%
%    Original FORTRAN77 version by Jack Dongarra, Cleve Moler, Jim Bunch, Pete Stewart.
%    This version by John Burkardt.
%
%  Input:
%
%    integer N, the order of the matrix.  If no value is supplied,
%    the default value of 1000 is used.
%
%    integer LDA, the leading dimension of the matrix.  
%    If no value is supplied, the default value of N+1 is used.
%
  timestamp ( );

  if ( nargin < 1 ) 
    n = 1000;
  end

  if ( nargin < 2 )
    lda = n + 1;
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, 'linpack_bench_backslash():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  The LINPACK benchmark.\n' );
  fprintf ( 1, '  Datatype: Real Double Precision\n' );
  fprintf ( 1, '  Matrix order N               = %d\n', n );
  fprintf ( 1, '  Leading matrix dimension LDA = %d\n', lda );

  A = 2.0 * rand ( n, n ) - 1.0;
  x_exact(1:n,1) = 1.0;
  b = A * x_exact;

  t = cputime ( );
  x = A \ b;
  t = cputime ( ) - t;
%
%  Compute the residual.
%
  r = b - A * x;
%
%  Compute infinity norms.
%
  A_norm = norm ( A, Inf );
  x_norm = norm ( x, Inf );
  r_norm = norm ( r, Inf );
%
%  Report.
%
  ratio = r_norm / A_norm / x_norm / eps;

  ops = ( 2 * n * n * n ) / 3.0 + 2.0 * ( n * n );
  mflops = ops / ( 1000000 * t );
  unit = 2.0 / mflops;

  cray = 0.056;
  cray_ratio = t / cray;

  fprintf ( 1, "\n" );
  fprintf ( 1, "  Normalized residual = %14f \n", ratio );
  fprintf ( 1, "  Residual norm       = %14f \n", r_norm );
  fprintf ( 1, "  Machine epsilon     = %14f \n", eps );
  fprintf ( 1, "  First X[]           = %14f \n", x(1) );
  fprintf ( 1, "  Last X[]            = %14f \n", x(n) );
  fprintf ( 1, "  Time in seconds     = %14f \n", t );
  fprintf ( 1, "  MegaFLOPS           = %14f \n", mflops );
  fprintf ( 1, "  Unit                = %14f \n", unit );
  fprintf ( 1, "  Cray ratio          = %14f \n", cray_ratio );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'linpack_bench_backslash():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  fprintf ( 1, '\n' );
  timestamp ( );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end
 
