simpeg.potential_fields.gravity.Simulation3DIntegral.getJtJdiag#
- Simulation3DIntegral.getJtJdiag(m, W=None, f=None)[source]#
Compute diagonal of
.- Parameters:
- m(n_param,)
numpy.ndarray
The model parameters.
- W(
nD
,nD
)np.ndarray
orscipy.sparse.sparray
,optional
Diagonal matrix with the square root of the weights. If not None, the function returns the diagonal of
.- f
Ignored
Not used, present here for API consistency by convention.
- m(n_param,)
- Returns:
- (
n_active_cells
)np.ndarray
Array with the diagonal of
J.T @ J
.
- (
Notes
If
store_sensitivities
is"forward_only"
, theG
matrix is never allocated in memory, and the diagonal is obtained by accumulation, computing each element of theG
matrix on the fly.This method caches the diagonal
G.T @ W.T @ W @ G
and the sha256 hash of the diagonal of theW
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 ofG.T @ W.T @ W @ G
.