Commit 6a838de7 authored by s.gretchko's avatar s.gretchko
Browse files

Fixed issues with bounds and reshaping in QNAP

parent f719d5c8
......@@ -83,7 +83,7 @@ class QNAP(Algorithm):
##### PREPROCESSING
iter = self.iter
prox1 = self.prox1;
prox1 = self.prox1
prox2 = self.prox2
if u.ndim < 3:
......@@ -145,9 +145,9 @@ class QNAP(Algorithm):
gradfnew_vec = (u[:,0]- tmp_u[:,0])
else:
if iter>3:
uold_vec= np.concatenate((np.real(u[:,0]), np.imag(u[:,0]))).reshape(self.Ny*self.Nx*2, 1)
uold_vec= np.concatenate((np.real(u[:,0]), np.imag(u[:,0]))).reshape(self.Ny*self.Nx*2)
unew_vec=np.concatenate((np.real(tmp_u[:,0]), np.imag(tmp_u[:,0]))).reshape(self.Ny*self.Nx*2, 1)
unew_vec=np.concatenate((np.real(tmp_u[:,0]), np.imag(tmp_u[:,0]))).reshape(self.Ny*self.Nx*2)
gradfold_vec = gradfnew_vec
gradfnew_vec = uold_vec-unew_vec
......@@ -167,16 +167,16 @@ class QNAP(Algorithm):
tmp_u[:,j]=tmp_u_vec
gap[iter-1]=gap[iter-1]/(self.Nx*self.Ny)
else:
uold_vec= np.array((np.real(u[:,0]), np.imag(u[:,0]))).reshape(self.Ny*self.Nx*2, 1)
unew_vec= np.array((np.real(tmp_u[:,0]), np.imag(tmp_u[:,0]))).reshape(self.Ny*self.Nx*2, 1)
uold_vec= np.array((np.real(u[:,0]), np.imag(u[:,0]))).reshape(self.Ny*self.Nx*2)
unew_vec= np.array((np.real(tmp_u[:,0]), np.imag(tmp_u[:,0]))).reshape(self.Ny*self.Nx*2)
gradfnew_vec = uold_vec-unew_vec
elif (p!=1) and (q==1):
if (np.all(isreal(u))):
tmp2 = u[:,:,0]
uold_vec= tmp2.reshape(self.Nx*self.Ny,1)
uold_vec= tmp2.reshape(self.Nx*self.Ny)
tmp2 = tmp_u[:,:,0]
unew_vec = tmp2.reshape(self.Nx*self.Ny,1)
unew_vec = tmp2.reshape(self.Nx*self.Ny)
if iter<=3:
gradfnew_vec = uold_vec-unew_vec
else:
......@@ -196,9 +196,9 @@ class QNAP(Algorithm):
else:
tmp2=np.concatenate((np.real(u[:,:,0]),np.imag(u[:,:,0])), axis=1)
uold_vec=tmp2.reshape(self.Nx*self.Ny*2,1)
uold_vec=tmp2.reshape(self.Nx*self.Ny*2)
tmp2= np.concatenate((np.real(tmp_u[:,:,0]), np.imag(tmp_u[:,:,0])), axis=1)
unew_vec = tmp2.reshape(self.Nx*self.Ny*2,1)
unew_vec = tmp2.reshape(self.Nx*self.Ny*2)
if iter<=3:
gradfnew_vec = uold_vec-unew_vec
else:
......@@ -212,7 +212,7 @@ class QNAP(Algorithm):
# now reshape and replace u
gap[iter-1]=gap[iter-1]/(self.Nx*self.Ny)
tmp2=unew_vec.reshape(self.Ny,self.Nx*2)
unew=tmp2[:,1:self.Nx] +1j*tmp2[:,self.Nx+1:2*self.Nx]
unew=tmp2[:,0:self.Nx] +1j*tmp2[:,self.Nx:2*self.Nx]
for j in range(self.product_space_dimension):
tmp_u[:,:,j]=unew
else: # product space of 3D arrays
......@@ -292,7 +292,7 @@ class QNAP(Algorithm):
self.u1 = tmp;
self.u2 = tmp2;
change=change[0:iter];
change=change[1:iter];
self.iter = iter;
print(self.iter)
self.change = change;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment