{ } Raw JSON

bundles / scipy 1.18.0 / scipy / optimize / _minpack / _chkder

built-in

scipy.optimize._minpack:_chkder

Signature

built-in_chkder(m, n, x, fvec, fjac, ldfjac, xp, fvecp, mode, err)

Summary

Check the gradients of a function against finite differences.

Extended Summary

Utility function for verifying correctness of user-supplied Jacobians.

Parameters

m : int

Number of functions (residuals).

n : int

Number of variables.

x : ndarray, shape (n,)

Point at which to check derivatives, float64.

fvec : ndarray, shape (m,)

Function values at x, float64. Used only when mode=2.

fjac : ndarray, shape (m, n)

User-supplied Jacobian at x, float64. Used only when mode=2.

ldfjac : int

Leading dimension of fjac.

xp : ndarray, shape (n,)

Perturbed point for finite differences, float64. Modified when mode=1, used when mode=2.

fvecp : ndarray, shape (m,)

Function values at xp, float64. Used only when mode=2.

mode : int

1: initialize xp for gradient checking. 2: compute error between analytical and finite-difference gradients.

err : ndarray, shape (m,)

Error estimates for each function, float64. Modified when mode=2.

Returns

: None

Modifies xp (when mode=1) or err (when mode=2) in-place.

Notes

This function is called twice: 1. mode=1: Computes perturbed point xp from x. 2. mode=2: Compares analytical Jacobian fjac with finite differences and stores relative errors in err.

Aliases

  • scipy.optimize._minpack._chkder