Input is changed after calling `evaluate`
Somehow, after calling evaluate
the initial matrix that I enter is changed by a factor of 2.
from scipy.sparse import diags, eye, csr_matrix, coo_matrix
import numpy as np
from lowdin.block_diagonalization import to_BlockSeries, general
H_0_AA = diags(np.arange(10, dtype=float) - 10)
H_0_BB = diags(np.arange(10, dtype=float) + 10)
h_AB = eye(10)
H_p_AB = {(1,): h_AB}
H_p_AA = {(1,): 0 * eye(10)}
H_p_BB = {(1,): 0 * eye(10)}
H = to_BlockSeries(H_0_AA, H_0_BB, H_p_AA, H_p_BB, H_p_AB)
def sparse_solve_sylvester(Y):
Y_coo = coo_matrix(Y)
E_A = H_0_AA.diagonal()
E_B = H_0_BB.diagonal()
Y_coo.data /= E_A[Y_coo.col] - E_B[Y_coo.row]
return csr_matrix(Y_coo)
H_tilde, U, U_adjoint = general(H, solve_sylvester=sparse_solve_sylvester)
print(H_0_AA.diagonal())
print(H_tilde.evaluated[0, 0, 0:1].data[0].diagonal())
print(H_0_AA.diagonal())
The output is:
[-10. -9. -8. -7. -6. -5. -4. -3. -2. -1.]
[-10. -9. -8. -7. -6. -5. -4. -3. -2. -1.]
[-5. -4.5 -4. -3.5 -3. -2.5 -2. -1.5 -1. -0.5]
Edited by Antonio Manesco