# Bug 63860: bicg problem
# This modified example also runs with 7.1.0 and higher
#
#   (I + s * a * aT) x = y
#
# --------------------------------------------------------------

# Define some parameters

  n   =   10;   % Matrix dimension
  s   = 1e-3;   % Scalar factor for perturbation
  tol = 1e-6;   % Tolerance

# Matrix a

  a = ones(n, 1);
  a = a / norm(a);

# Right-hand side

  y = zeros(n, 1);
  y(1 : 2 : n) = 1;

# Anonymous function to compute matrix product

  Amat = @(x, type, s) x + (s * a) * (a' * x);

# Anonymous function to compute identity

  idn = @(x, type, s) x;

# Solve

  x0 = y;
  [x, flag, ~, niter] = bicg(Amat, y, tol, [], idn, idn,
                             x0, s);
  printf("x = %10.5f\n", x);
  printf("flag = %2.0f, niter = %2.0f\n", flag, niter);

# Test solution

  r = y - x - (s * a) * (a' * x);
  printf("r = %10.5e\n", r);
  printf("|r| = %10.5e, tol * |y| = %10.5e\n", 
         norm(r), tol * norm(y));
