Gvar extensions¶
- lsqfitgp.gvar_gufunc(func, *, signature=None)[source]¶
- Wraps a jax-traceable generalized ufunc with one argument to support gvars. - Parameters:
- funccallable
- A function from one array to one array. It must be a generalized ufunc, and differentiable one time with - jax.
- signaturestr, optional
- The signature of the generalized ufunc. If not specified, it is assumed to be scalar to scalar (normal ufunc). 
 
- Returns:
- decorated_funccallable
- A function that, in addition to numerical arrays, accepts gvars and returns gvars. 
 
 - See also 
- lsqfitgp.switchgvar()[source]¶
- Context manager to keep new gvars in a separate pool. - Creating new primary gvars fills up memory permanently. This context manager keeps the gvars created within its context in a separate pool that is freed when all such gvars are deleted. They can not be mixed in operations with other gvars created outside of the context. - Returns:
- gvargvar.GVarFactory
- The new gvar-creating function that uses a new pool. The change is also reflected in the global - gvar.gvar.
 
 - See also - Examples - >>> x = gvar.gvar(0, 1) >>> with lgp.switchgvar(): >>> y = gvar.gvar(0, 1) >>> z = gvar.gvar(0, 1) >>> w = gvar.gvar(0, 1) >>> q = y + z # allowed, y and z created in the same pool >>> p = x + w # allowed, x and w created in the same pool >>> h = x + y # x and y created in different pools: this will silently ... # fail and possibly crash python immediately or later on 
- lsqfitgp.jacobian(g)[source]¶
- Extract the jacobian of gvars w.r.t. primary gvars. - Parameters:
- garray_like
- An array of numbers or gvars. 
 
- Returns:
- jacarray
- The shape is g.shape + (m,), where m is the total number of primary gvars that g depends on. 
- indices(m,) int array
- The indices that map the last axis of jac to primary gvars in the global covariance matrix. 
 
 - See also 
- lsqfitgp.from_jacobian(mean, jac, indices)[source]¶
- Create new gvars from a jacobian w.r.t. primary gvars. - Parameters:
- meanarray_like
- An array of numbers with the means of the new gvars. 
- jacmean.shape + (m,) array
- The derivatives of each new gvar w.r.t. m primary gvars. 
- indices(m,) int array
- The indices of the primary gvars. 
 
- Returns:
- gmean.shape array
- The new gvars. 
 
 - See also