SimPEG.utils.sdinv#
- SimPEG.utils.sdinv(M)[source]#
- Return inverse of a sparse diagonal matrix. - This function extracts the diagonal elements of the input matrix M and creates a sparse diagonal matrix from the reciprocal these elements. If the input matrix M is diagonal, the output is the inverse of M. - Parameters
- M(n,n)scipy.sparse.csr_matrix
- A sparse diagonal matrix 
 
- M(
- Returns
- (n,n)scipy.sparse.csr_matrix
- The inverse of the sparse diagonal matrix. 
 
- (
 - Examples - >>> from discretize.utils import sdiag, sdinv >>> import numpy as np - >>> v = np.array([6., 3., 1., 8., 0., 5.]) >>> M = sdiag(v) >>> Minv = sdinv(M)