pygsti.optimize.optimize.check_jac

Contents

pygsti.optimize.optimize.check_jac#

check_jac(f, x0, jac_to_check, eps=1e-10, tol=1e-06, err_type='rel', verbosity=1)#

Checks a jacobian function using finite differences.

Parameters:
  • f (function) – The function to check.

  • x0 (numpy array) – The point at which to check the jacobian.

  • jac_to_check (function) – A function which should compute the jacobian of f at x0.

  • eps (float, optional) – Epsilon to use in finite difference calculations of jacobian.

  • tol (float, optional) – The allowed tolerance on the relative difference between the values of the finite difference and jac_to_check jacobians if err_type == ‘rel’ or the absolute difference if err_type == ‘abs’.

  • err_type ({'rel', 'abs'), optional) – How to interpret tol (see above).

  • verbosity (int, optional) – Controls how much detail is printed to stdout.

Returns:

  • errSum (float) – The total error between the jacobians.

  • errs (list) – List of (row,col,err) tuples giving the error for each row and column.

  • ffd_jac (numpy array) – The computed forward-finite-difference jacobian.