pennylane icon indicating copy to clipboard operation
pennylane copied to clipboard

Exponential operator wrapper

Open albi3ro opened this issue 2 years ago • 2 comments

This wrapper allows us to represent the exponential of an operator. It has an optional keyword argument that allows the specification of a scalar coefficient. This allows us to easily represent general rotation gates.

In this example, we are able to mimic the behaviour of RX:

>>> x = np.array(1.23)
>>> op = Exp( qml.PauliX(0), -0.5j * x)
>>> qml.math.allclose(op.matrix(), qml.RX(x, wires=0).matrix())
True

The coefficient is optional and defaults to 1:

Exp(qml.PauliX(0))

albi3ro avatar Jul 07 '22 19:07 albi3ro

Hello. You may have forgotten to update the changelog! Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

github-actions[bot] avatar Jul 07 '22 20:07 github-actions[bot]

Codecov Report

Merging #2799 (da9aba0) into master (17a2317) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #2799   +/-   ##
=======================================
  Coverage   99.65%   99.65%           
=======================================
  Files         267      268    +1     
  Lines       22417    22489   +72     
=======================================
+ Hits        22340    22412   +72     
  Misses         77       77           
Impacted Files Coverage Δ
pennylane/devices/default_qubit.py 100.00% <ø> (ø)
pennylane/operation.py 96.83% <ø> (ø)
pennylane/__init__.py 100.00% <100.00%> (ø)
pennylane/ops/op_math/__init__.py 100.00% <100.00%> (ø)
pennylane/ops/op_math/exp.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Jul 07 '22 20:07 codecov[bot]