Skip to content

Commit

Permalink
Matrix exponential of sparse matrix is not allowed (#800)
Browse files Browse the repository at this point in the history
- The matrix exponential of these sparse matrices is causing errors
in certain versions of scipy:
"loop of ufunc does not support argument 0 of type csc_matrix which has
no callable exp method"

- Converting these to dense matrices to get docs working again.
  • Loading branch information
dstrain115 committed Sep 16, 2022
1 parent deac822 commit 16fa379
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/fqe/tutorials/diagonal_coulomb_evolution.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@
"outputs": [],
"source": [
"cirq_wfn = fqe.to_cirq(fqe_wfn).reshape((-1, 1))\n",
"final_cirq_wfn = expm(-1j * of.get_sparse_operator(diagonal_coulomb)) @ cirq_wfn\n",
"final_cirq_wfn = expm(-1j * of.get_sparse_operator(diagonal_coulomb).todense()) @ cirq_wfn\n",
"# recover a fqe wavefunction\n",
"from_cirq_wfn = fqe.from_cirq(final_cirq_wfn.flatten(), 1.0E-8)\n"
]
Expand Down
2 changes: 1 addition & 1 deletion docs/fqe/tutorials/fermi_hubbard.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
"init_cirq_wfn = fqe.to_cirq(init_wfn)\n",
"\n",
"# Exponentiate the (sparse) Hamiltonian U = exp(-i H t).\n",
"unitary = expm(-1j * e_time * of.get_sparse_operator(hubbard))\n",
"unitary = expm(-1j * e_time * of.get_sparse_operator(hubbard).todense())\n",
"\n",
"# Do the time evolution |𝛹'⟩ = U |𝛹⟩.\n",
"true_evolved_cirq = unitary @ init_cirq_wfn"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
"source": [
"# full space unitary\n",
"time = np.random.random()\n",
"hamiltonian_evolution = expm(-1j * ikappa_mat * time) "
"hamiltonian_evolution = expm(-1j * ikappa_mat.todense() * time) "
]
},
{
Expand Down

0 comments on commit 16fa379

Please sign in to comment.