@@ -92,7 +92,7 @@ def setup(
9292 self .r = self .y - self .Op .matvec (x )
9393 self .rank = x .rank
9494 self .c = self .r .copy ()
95- self .kold = float (np .abs (self .r .dot (self .r .conj ())))
95+ self .kold = float (np .abs (self .r .dot (self .r .conj ())). item () )
9696
9797 # create variables to track the residual norm and iterations
9898 self .cost : List = []
@@ -127,10 +127,10 @@ def step(self, x: Union[DistributedArray, StackedDistributedArray],
127127 """
128128 Opc = self .Op .matvec (self .c )
129129 cOpc = np .abs (self .c .dot (Opc .conj ()))
130- a = float (self .kold / cOpc )
130+ a = float (( self .kold / cOpc ). item () )
131131 x += a * self .c
132132 self .r -= a * Opc
133- k = float (np .abs (self .r .dot (self .r .conj ())))
133+ k = float (np .abs (self .r .dot (self .r .conj ())). item () )
134134 b = float (k / self .kold )
135135 self .c = self .r + b * self .c
136136 self .kold = k
@@ -349,13 +349,13 @@ def setup(self,
349349 self .rank = x .rank
350350 self .c = r .copy ()
351351 self .q = self .Op .matvec (self .c )
352- self .kold = float (np .abs (r .dot (r .conj ())))
352+ self .kold = float (np .abs (r .dot (r .conj ())). item () )
353353
354354 # create variables to track the residual norm and iterations
355355 self .cost = []
356356 self .cost1 = []
357- self .cost .append (float (self .s .norm ()))
358- self .cost1 .append (np .sqrt (float (self .cost [0 ] ** 2 + damp * np .abs (x .dot (x .conj ())))))
357+ self .cost .append (float (self .s .norm (). item () ))
358+ self .cost1 .append (np .sqrt (float (self .cost [0 ] ** 2 + damp * np .abs (x .dot (x .conj ())). item () )))
359359 self .iiter = 0
360360
361361 # print setup
@@ -386,19 +386,19 @@ def step(self, x: Union[DistributedArray, StackedDistributedArray],
386386
387387 """
388388
389- a = float (np .abs (self .kold / (self .q .dot (self .q .conj ()) + self .damp * self .c .dot (self .c .conj ()))))
389+ a = float (np .abs (self .kold / (self .q .dot (self .q .conj ()) + self .damp * self .c .dot (self .c .conj ()))). item () )
390390 x += a * self .c
391391 self .s -= a * self .q
392392 damped_x = self .damp * x
393393 r = self .Op .rmatvec (self .s ) - damped_x
394- k = float (np .abs (r .dot (r .conj ())))
394+ k = float (np .abs (r .dot (r .conj ())). item () )
395395 b = float (k / self .kold )
396396 self .c = r + b * self .c
397397 self .q = self .Op .matvec (self .c )
398398 self .kold = k
399399 self .iiter += 1
400- self .cost .append (float (self .s .norm ()))
401- self .cost1 .append (np .sqrt (float (self .cost [self .iiter ] ** 2 + self .damp * np .abs (x .dot (x .conj ())))))
400+ self .cost .append (float (self .s .norm (). item () ))
401+ self .cost1 .append (np .sqrt (float (self .cost [self .iiter ] ** 2 + self .damp * np .abs (x .dot (x .conj ())). item () )))
402402 if show and self .rank == 0 :
403403 self ._print_step (x )
404404 return x
0 commit comments