def sffile2d(array, o, d, n, o2, d2, n2): a = rsf.File(array) return rsf.put(n1=n, o1=o, d1=d, n2=n2, o2=o2, d2=d2, n3=1)[a]
for iter in range(niter): g = oper(adj=1)[R] G = oper(adj=0)[g] RG = R.dot(G) print "iter %d: %g" % (iter+1,RG) alpha = - RG/G.dot(G) x = x+g*alpha R = R+G*alpha return x if __name__ == "__main__": # test matrix and data matrix = rsf.File([[1,1,1,0], [1,2,0,0], [1,3,1,0], [1,4,0,1], [1,5,1,1]]) y = rsf.File([3,3,5,7,9]) x0 = rsf.File([0,0,0,0]) # matrix multiplication operator matmult = rsf.matmult(mat=matrix) # Using function above x = steepd(matmult,y,x0,100) y2 = matmult[x] print x[:] print y2[:]
def sffile1d(array, o, d, n): a = rsf.File(array) # here i am creating an rsf file from numpy array return rsf.put(n1=n, o1=o, d1=d, n2=1, n3=1)[a]