simpeg.potential_fields.magnetics.SimulationEquivalentSourceLayer.getJtJdiag#
- SimulationEquivalentSourceLayer.getJtJdiag(m, W=None, f=None)[source]#
Compute diagonal of \(\mathbf{J}^T \mathbf{J}`\).
- Parameters:
- m(n_param,)
numpy.ndarray The model parameters.
- W(
nD,nD)np.ndarrayorscipy.sparse.sparray,optional Diagonal matrix with the square root of the weights. If not None, the function returns the diagonal of \(\mathbf{J}^T \mathbf{W}^T \mathbf{W} \mathbf{J}`\).
- f
Ignored Not used, present here for API consistency by convention.
- m(n_param,)
- Returns:
- (
nparam)np.ndarray Array with the diagonal of
J.T @ J.
- (
Notes
If
store_sensitivitiesis"forward_only", theGmatrix is never allocated in memory, and the diagonal is obtained by accumulation, computing each element of theGmatrix on the fly.This method caches the diagonal
G.T @ W.T @ W @ Gand the sha256 hash of the diagonal of theWmatrix. This way, if same weights are passed to it, it reuses the cached diagonal so it doesn’t need to be recomputed. If new weights are passed, the cache is updated with the latest diagonal ofG.T @ W.T @ W @ G.