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

Add invert functionality for quantum operations #416

Merged
merged 1 commit into from
Sep 13, 2023

Conversation

martin-fink
Copy link
Collaborator

@martin-fink martin-fink commented Sep 7, 2023

Description

Add an invert function to Operation. This mirrors the functionality of the OpenQASM 3.0 inv modifier.

For Compound gates, this calls invert on each nested operation and reverses the order of the operations.
For Standard gates, this checks which type of gate is being inverted and handles each case.

Checklist:

  • The pull request only contains commits that are related to it.
  • I have added appropriate tests and documentation.
  • I have made sure that all CI jobs on GitHub pass.
  • The pull request introduces no new warnings and follows the project's style guidelines.

src/operations/StandardOperation.cpp Outdated Show resolved Hide resolved
include/operations/Operation.hpp Show resolved Hide resolved
@martin-fink martin-fink marked this pull request as ready for review September 11, 2023 17:26
Copy link
Member

@burgholzer burgholzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, many thanks for this nice and neatly organized contribution.
As in the other PR I have a few minor nitpicks and a reply to one of the general questions you posted in a comment. Should be pretty straight-forward to realize.

include/operations/Operation.hpp Show resolved Hide resolved
src/operations/StandardOperation.cpp Outdated Show resolved Hide resolved
src/operations/SymbolicOperation.cpp Outdated Show resolved Hide resolved
src/operations/SymbolicOperation.cpp Outdated Show resolved Hide resolved
test/unittests/test_qfr_functionality.cpp Outdated Show resolved Hide resolved
test/unittests/test_qfr_functionality.cpp Show resolved Hide resolved
test/unittests/test_qfr_functionality.cpp Outdated Show resolved Hide resolved
Copy link
Member

@burgholzer burgholzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, some finishing touches before this is ready to merge.

include/operations/Operation.hpp Show resolved Hide resolved
src/operations/StandardOperation.cpp Outdated Show resolved Hide resolved
src/operations/StandardOperation.cpp Outdated Show resolved Hide resolved
src/operations/StandardOperation.cpp Show resolved Hide resolved
src/operations/SymbolicOperation.cpp Outdated Show resolved Hide resolved
test/unittests/test_qfr_functionality.cpp Show resolved Hide resolved
@burgholzer burgholzer added feature New feature or request Core Anything related to the Core library and IR c++ Anything related to C++ code labels Sep 13, 2023
@burgholzer burgholzer added this to the OpenQASM 3.0 Support milestone Sep 13, 2023
Copy link
Member

@burgholzer burgholzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✅ Many thanks!
Would you mind quickly resolving the conflicts with the main branch that arose from the other PR just getting merged? Then this can be merged as well!

@martin-fink
Copy link
Collaborator Author

Rebased! Thanks!

@burgholzer burgholzer enabled auto-merge (squash) September 13, 2023 18:16
@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Merging #416 (50726ba) into main (cc34cbc) will increase coverage by 0.0%.
The diff coverage is 95.9%.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff           @@
##            main    #416    +/-   ##
======================================
  Coverage   89.5%   89.5%            
======================================
  Files        102     102            
  Lines      11820   11923   +103     
  Branches    2095    2098     +3     
======================================
+ Hits       10580   10680   +100     
- Misses      1240    1243     +3     
Flag Coverage Δ
cpp 89.5% <95.9%> (+<0.1%) ⬆️
python 100.0% <ø> (ø)
Files Changed Coverage Δ
include/operations/ClassicControlledOperation.hpp 87.5% <0.0%> (-1.6%) ⬇️
include/operations/NonUnitaryOperation.hpp 100.0% <ø> (ø)
include/operations/StandardOperation.hpp 100.0% <ø> (ø)
include/operations/SymbolicOperation.hpp 100.0% <ø> (+4.3%) ⬆️
src/operations/StandardOperation.cpp 93.5% <94.7%> (+0.2%) ⬆️
include/operations/CompoundOperation.hpp 86.7% <100.0%> (+0.5%) ⬆️
include/operations/Operation.hpp 95.6% <100.0%> (+0.2%) ⬆️
src/operations/SymbolicOperation.cpp 82.7% <100.0%> (+3.1%) ⬆️

... and 1 file with indirect coverage changes

@burgholzer burgholzer merged commit 6df3338 into cda-tum:main Sep 13, 2023
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Anything related to C++ code Core Anything related to the Core library and IR feature New feature or request
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants