Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduction of addition and multiplication to the Hamiltonian #55

Merged
merged 7 commits into from
Aug 20, 2024

Conversation

Jacomichi
Copy link
Collaborator

Change

  • I have introduced addition and multiplication to the Hamiltonian.
  • The return values of X(idx), Y(idx), and Z(idx) have been changed to the Hamiltonian class.
  • Fixed a bug in the conversion to qiskit Hamiltonian.
  • I have introduced Pauli.I.

Example

import qamomile.core.operator as qm_o

x0 = qm_o.X(0)
h1 = 2.0 * x0 + 1.0
h = h1 * h1 # 4x0 + 5.0
expected_h = qm_o.Hamiltonian()
expected_h.constant += 5.0
expected_h.add_term((qm_o.PauliOperator(qm_o.Pauli.X, 0),), 4.0)

assert h == expected_h

@Jacomichi Jacomichi requested a review from yuyamashiro August 19, 2024 11:46
@Jacomichi Jacomichi added the enhancement New feature or request label Aug 19, 2024
@yuyamashiro yuyamashiro merged commit b21f2e7 into main Aug 20, 2024
6 checks passed
@yuyamashiro yuyamashiro deleted the feature/hamiltonian_arithmetic branch August 20, 2024 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants