mirror of
https://github.com/wassname/simpeg.git
synced 2026-06-30 00:33:27 +08:00
Cleaned utils code, merged in subArray.
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
import numpy as np
|
||||
|
||||
def getSubArray(A,ind):
|
||||
"""subArray"""
|
||||
i = ind[0]; j = ind[1]; k = ind[2]
|
||||
|
||||
return A[i,:,:][:,j,:][:,:,k]
|
||||
|
||||
+12
-7
@@ -1,5 +1,5 @@
|
||||
import numpy as np
|
||||
from numpy import *
|
||||
|
||||
|
||||
def reshapeF(x, size):
|
||||
return np.reshape(x, size, order='F')
|
||||
@@ -106,13 +106,13 @@ def ind2sub(shape, ind):
|
||||
mult = [1]
|
||||
for i in range(0, len(revshp)-1):
|
||||
mult.extend([mult[i]*revshp[i]])
|
||||
mult = array(mult).reshape(len(mult))
|
||||
mult = np.array(mult).reshape(len(mult))
|
||||
|
||||
sub = []
|
||||
|
||||
for i in range(0, len(shape)):
|
||||
sub.extend([math.floor(ind / mult[i])])
|
||||
ind = ind - (math.floor(ind/mult[i]) * mult[i])
|
||||
sub.extend([np.math.floor(ind / mult[i])])
|
||||
ind = ind - (np.math.floor(ind/mult[i]) * mult[i])
|
||||
return sub
|
||||
|
||||
|
||||
@@ -122,7 +122,12 @@ def sub2ind(shape, subs):
|
||||
mult = [1]
|
||||
for i in range(0, len(revshp)-1):
|
||||
mult.extend([mult[i]*revshp[i]])
|
||||
mult = array(mult).reshape(len(mult), 1)
|
||||
mult = np.array(mult).reshape(len(mult), 1)
|
||||
|
||||
idx = dot((subs), (mult))
|
||||
return idx
|
||||
idx = np.dot((subs), (mult))
|
||||
return idx
|
||||
|
||||
|
||||
def getSubArray(A, ind):
|
||||
"""subArray"""
|
||||
return A[ind[0], :, :][:, ind[1], :][:, :, ind[2]]
|
||||
|
||||
Reference in New Issue
Block a user