Skip to content

Commit

Permalink
Implement arithmetic on SparseObservable
Browse files Browse the repository at this point in the history
The simple arithmetic operators of addition, subtraction,
multiplication, division and tensor product are in line with other
`quantum_info` objects, including coercion from other objects (though
better behaved on failed coercions, in many cases).

Where appopriate, in-place operations will re-use the existing
allocations.  The tensor product cannot really be done in place, so it
doesn't define a special `__rxor__` operator, but it inherits the
standard Python behaviour of this being derived from `__xor__`.

There are further mathematical operations to add around composition and
evolution, and to apply a `TranspileLayout` to the observable.  All of
these, in the `quantum_info` style either directly deal with a layout,
or take a `qargs` argument that is effectively a sublayout for the
right-hand side of the operation.  These will be added in a follow-up.
  • Loading branch information
jakelishman committed Oct 24, 2024
1 parent 2284f19 commit 68b5c56
Show file tree
Hide file tree
Showing 2 changed files with 1,478 additions and 44 deletions.
Loading

0 comments on commit 68b5c56

Please sign in to comment.