@@ -134,18 +134,18 @@ def body_vector(i, vals):
134134 krv , unitary , states = vals
135135 dim = unitary .shape [1 ]
136136 n , m = jax .numpy .divmod (i , dim )
137- states = jax .ops .index_add (states , jax .ops .index [n ],
137+ states = jax .ops .index_add (states , jax .ops .index [n , : ],
138138 krv [m + 1 , :] * unitary [m , n ])
139139 return [krv , unitary , states ]
140140
141- state_vector = jax .numpy .zeros ([neig , numel ], dtype = init .dtype )
142- _ , _ , vector = jax .lax .fori_loop (0 , neig * (krylov_vecs .shape [0 ] - 1 ),
143- body_vector ,
144- [krylov_vecs , U , state_vector ])
145- vector /= jax . numpy . linalg . norm ( vector )
141+ state_vectors = jax .numpy .zeros ([neig , numel ], dtype = init .dtype )
142+ _ , _ , vectors = jax .lax .fori_loop (0 , neig * (krylov_vecs .shape [0 ] - 1 ),
143+ body_vector ,
144+ [krylov_vecs , U , state_vectors ])
145+
146146 return jax .numpy .array (eigvals [0 :neig ]), [
147- jax .numpy .reshape (vector [n , :], init .shape ) /
148- jax .numpy .linalg .norm (vector [n , :]) for n in range (neig )
147+ jax .numpy .reshape (vectors [n , :], init .shape ) /
148+ jax .numpy .linalg .norm (vectors [n , :]) for n in range (neig )
149149 ]
150150
151151 return jax_lanczos
0 commit comments