SimPEG.utils.sdiag#
- SimPEG.utils.sdiag(v)[source]#
- Generate sparse diagonal matrix from a vector. - This function creates a sparse diagonal matrix whose diagonal elements are defined by the input vector v. For a vector of length n, the output matrix has shape (n,n). - Parameters
- v(n)numpy.ndarrayordiscretize.utils.Zero
- The vector defining the diagonal elements of the sparse matrix being constructed 
 
- v(
- Returns
- (n,n)scipy.sparse.csr_matrixordiscretize.utils.Zero
- The sparse diagonal matrix. 
 
- (
 - Examples - Use a 1D array of values to construct a sparse diagonal matrix. - >>> from discretize.utils import sdiag >>> import numpy as np >>> v = np.array([6., 3., 1., 8., 0., 5.]) >>> M = sdiag(v) 
Galleries and Tutorials using SimPEG.utils.sdiag#
 
Heagy et al., 2017 1D RESOLVE Bookpurnong Inversion
Heagy et al., 2017 1D RESOLVE Bookpurnong Inversion
 
