You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently using openfermion.ops.QuadOperator and I wanted to check out some relations I derived which required me to represent the symbolic QuadOperator as an array in the N^M x N^M Hilbertspace, where N is the truncation of the bosonic levels and M is the number of bosonic modes.
I have the following very simple problem: I want to write the QuadOperator a_quad_operator_on_mode_0 = of.ops.QuadOperator(((0, 'q')), 1)
as a NM x NM array, by first converting it to sparse object and then to an array through array_example_1 = of.boson_operator_sparse(a_quad_operator_on_mode_0, N, hbar=2).toarray()
The issue is that in this particular instance, if I e.g. choose N=5 and M = 3, i will get array_example_1.shape = (5,5), instead of (125,125).
If instead of a_quad_operator_on_mode_0 I compute a_quad_operator_on_mode_1 = of.ops.QuadOperator(((1, 'q')), 1) then I get a_quad_operator_on_mode_1.shape = (25,25) and similarly a_quad_operator_on_mode_2 = of.ops.QuadOperator(((2, 'q')), 1) then I get a_quad_operator_on_mode_1.shape = (125,125).
One work-around would be to artificially insert the identity [q_j, p_j] = 2i on the modes j which are not k in of.ops.QuadOperator(((k, 'q')), 1)... but this seems like a super inefficient way. Any suggestions? Even just including that identity on the first and last mode (if either one is not k) would be enough already
Thanks!
Michael.
PS: In FermionOperator class it is a bit nicer, since there you can specify the number of modes in your system when using get_sparse_operator.
The text was updated successfully, but these errors were encountered:
Hi all,
I am currently using openfermion.ops.QuadOperator and I wanted to check out some relations I derived which required me to represent the symbolic QuadOperator as an array in the N^M x N^M Hilbertspace, where N is the truncation of the bosonic levels and M is the number of bosonic modes.
I have the following very simple problem: I want to write the QuadOperator
a_quad_operator_on_mode_0 = of.ops.QuadOperator(((0, 'q')), 1)
as a NM x NM array, by first converting it to sparse object and then to an array through
array_example_1 = of.boson_operator_sparse(a_quad_operator_on_mode_0, N, hbar=2).toarray()
The issue is that in this particular instance, if I e.g. choose N=5 and M = 3, i will get array_example_1.shape = (5,5), instead of (125,125).
If instead of a_quad_operator_on_mode_0 I compute
a_quad_operator_on_mode_1 = of.ops.QuadOperator(((1, 'q')), 1)
then I get a_quad_operator_on_mode_1.shape = (25,25) and similarlya_quad_operator_on_mode_2 = of.ops.QuadOperator(((2, 'q')), 1)
then I get a_quad_operator_on_mode_1.shape = (125,125).One work-around would be to artificially insert the identity [q_j, p_j] = 2i on the modes j which are not k in
of.ops.QuadOperator(((k, 'q')), 1)
... but this seems like a super inefficient way. Any suggestions? Even just including that identity on the first and last mode (if either one is not k) would be enough alreadyThanks!
Michael.
PS: In FermionOperator class it is a bit nicer, since there you can specify the number of modes in your system when using get_sparse_operator.
The text was updated successfully, but these errors were encountered: