simpeg.potential_fields.gravity.Simulation3DIntegral.getJtJdiag#

Simulation3DIntegral.getJtJdiag(m, W=None, f=None)[source]#

Compute diagonal of JTJ.

Parameters:
m(n_param,) numpy.ndarray

The model parameters.

W(nD, nD) np.ndarray or scipy.sparse.sparray, optional

Diagonal matrix with the square root of the weights. If not None, the function returns the diagonal of JTWTWJ.

fIgnored

Not used, present here for API consistency by convention.

Returns:
(n_active_cells) np.ndarray

Array with the diagonal of J.T @ J.

Notes

If store_sensitivities is "forward_only", the G matrix is never allocated in memory, and the diagonal is obtained by accumulation, computing each element of the G matrix on the fly.

This method caches the diagonal G.T @ W.T @ W @ G and the sha256 hash of the diagonal of the W matrix. 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 of G.T @ W.T @ W @ G.