mirror of
https://github.com/wassname/simpeg.git
synced 2026-08-05 13:20:43 +08:00
Put utils in their own folder. Increases organization, and everything will be available under SimPEG.utils
NOTE: if you add a new function (or file), you must register it in __init__.py for it to be available under: e.g. ... from utils import mkvc, … ... from MYNEWFILE import MYNEWFUNCTION
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
from scipy import sparse as sp
|
||||
from utils import mkvc
|
||||
|
||||
|
||||
def sdiag(h):
|
||||
"""Sparse diagonal matrix"""
|
||||
return sp.spdiags(mkvc(h), 0, h.size, h.size, format="csr")
|
||||
|
||||
|
||||
def speye(n):
|
||||
"""Sparse identity"""
|
||||
return sp.identity(n, format="csr")
|
||||
|
||||
|
||||
def kron3(A, B, C):
|
||||
"""Three kron prods"""
|
||||
return sp.kron(sp.kron(A, B), C, format="csr")
|
||||
|
||||
|
||||
def spzeros(n1, n2):
|
||||
"""spzeros"""
|
||||
return sp.coo_matrix((n1, n2)).tocsr()
|
||||
Reference in New Issue
Block a user