Skip to content

Commit 94932b9

Browse files
vsoftcoa3moses
andauthored
Conditional statements (#178)
* Initial stab at conditionals Signed-off-by: Vlad Gheorghiu <[email protected]> * Removed trailing whitespaces in qasm files Signed-off-by: Vlad Gheorghiu <[email protected]> * Update Signed-off-by: Vlad Gheorghiu <[email protected]> * Update Signed-off-by: Vlad Gheorghiu <[email protected]> * Update Signed-off-by: Vlad Gheorghiu <[email protected]> * update Signed-off-by: Vlad Gheorghiu <[email protected]> * update Signed-off-by: Vlad Gheorghiu <[email protected]> * Changed qasm IfStmt to use cond_if * Conditionals now work. Small changes to execute and QCircuitIterator. * fix QBaseEngine * fix to execute_circuit_steps_once_, all unit tests pass. * made iterator_type a value, not a reference * formatting * removed LOGs * Update qengine.hpp * Fix to conditionals, added conditionals to pyqpp. * made measured_d_ a stack in qcircuit.hpp * formatting * Update qcircuit.hpp * Update qcircuit_conditional_step.hpp * Added WHILE and ENDWHILE, extra exception checks * minor update * Update qpp.hpp * Changes to QCircuitConditionalStep * while_pos_ to outer_while_pos_ * updated (c) notice Updated (c) notice * update * Added conditional_if/while examples Signed-off-by: Vlad Gheorghiu <[email protected]> * Preparing for Version 6.0 Signed-off-by: Vlad Gheorghiu <[email protected]> * Updated README.md Signed-off-by: Vlad Gheorghiu <[email protected]> * Minor update Signed-off-by: Vlad Gheorghiu <[email protected]> * Fixed typo Signed-off-by: Vlad Gheorghiu <[email protected]> * Added Windows CI Signed-off-by: Vlad Gheorghiu <[email protected]> * Member var zero-init Signed-off-by: Vlad Gheorghiu <[email protected]> * fixing Windows CI Signed-off-by: Vlad Gheorghiu <[email protected]> * fixing Windows CI Signed-off-by: Vlad Gheorghiu <[email protected]> * Finished fixing Windows CI Signed-off-by: Vlad Gheorghiu <[email protected]> * Minor stylystic updates to pyqpp Signed-off-by: Vlad Gheorghiu <[email protected]> * Spacing Signed-off-by: Vlad Gheorghiu <[email protected]> * Minor stylistic update Signed-off-by: Vlad Gheorghiu <[email protected]> * Updated CODE_OF_CONDUCT.md Signed-off-by: Vlad Gheorghiu <[email protected]> * Update Signed-off-by: Vlad Gheorghiu <[email protected]> * Update Signed-off-by: Vlad Gheorghiu <[email protected]> * Fix Signed-off-by: Vlad Gheorghiu <[email protected]> * Yet more fixes, all tests pass Signed-off-by: Vlad Gheorghiu <[email protected]> * More fixes Signed-off-by: Vlad Gheorghiu <[email protected]> * Preparing v6.0 Signed-off-by: Vlad Gheorghiu <[email protected]> * typo Signed-off-by: Vlad Gheorghiu <[email protected]> * Preparing for v6.0 Signed-off-by: Vlad Gheorghiu <[email protected]> * Update qbase_engine.hpp * Version 6.0 Signed-off-by: Vlad Gheorghiu <[email protected]> --------- Signed-off-by: Vlad Gheorghiu <[email protected]> Co-authored-by: a3moses <[email protected]>
1 parent 78119fb commit 94932b9

File tree

112 files changed

+2565
-1355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+2565
-1355
lines changed

.github/workflows/cmake.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ jobs:
1313
build:
1414
strategy:
1515
matrix:
16-
# os: [ubuntu-latest, macos-latest, windows-latest]
17-
os: [ubuntu-latest, macos-latest]
16+
os: [ubuntu-latest, macos-latest, windows-latest]
1817
runs-on: ${{ matrix.os }}
1918

2019
steps:
@@ -70,7 +69,7 @@ jobs:
7069
run: |
7170
python3 -mvenv venv
7271
if [ "$RUNNER_OS" == "Windows" ]; then
73-
venv\Scripts\Activate
72+
venv/Scripts/Activate
7473
else
7574
source venv/bin/activate
7675
fi

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,4 @@ cmake_install.cmake
7474
CMakeCache.txt
7575
CMakeFiles/
7676
pyqpp.egg-info/
77+
/uv.lock

CHANGES.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Pre-release
1+
# Version 6.0 - 14 April 2025
22

33
- Breaking change: renamed ["qpp/qpp.h"] to ["qpp/qpp.hpp"]
44
- New feature: implemented support for post-selection in
@@ -22,6 +22,22 @@
2222
- Added
2323
[["examples/circuits/post_selection.cpp"](https://github.com/softwareQinc/qpp/blob/main/examples/circuits/post_selection.cpp)]
2424
example
25+
- New feature: implemented support for conditional statements in
26+
["qpp/classes/qcircuit.hpp"]
27+
- Implemented `qpp::QCircuit::`
28+
- `QCircuit& cond_if()` - conditional IF statement
29+
- `QCircuit& cond_else()` - conditional ELSE statement
30+
- `QCircuit& cond_while()` - conditional WHILE statement
31+
- `QCircuit& cond_end()` - conditional END block delimiter
32+
- `bool has_conditionals() const noexcept` - true if and only if the circuit contains
33+
conditional statements
34+
- `bool validate_conditionals() const` - true if an only if the conditional
35+
statements are valid (e.g., matching `cond_end()` to `cond_if()` etc.
36+
- Added
37+
[["examples/circuits/conditional_if.cpp"](https://github.com/softwareQinc/qpp/blob/main/examples/circuits/conditional_if.cpp)]
38+
and
39+
[["examples/circuits/conditional_while.cpp"](https://github.com/softwareQinc/qpp/blob/main/examples/circuits/conditional_while.cpp)]
40+
examples
2541
- Refactored `qpp::QCircuit::GateStep/MeasurementStep/NOPStep` into separate
2642
files ["qpp/internal/classes/qcircuit_gate_step.hpp"],
2743
["qpp/internal/classes/qcircuit_measurement_step.hpp"], and
@@ -43,13 +59,17 @@
4359
- `qpp::QEngineT<>::get_non_measured()` ->
4460
`qpp::QEngineT<>::get_non_measured_d()`
4561
- `qpp::QEngineT<>::was_measured()` -> `qpp::QEngineT<>::was_measured_d()`
46-
- Bugfix in qpp::internal::canonical_form(), the re-ordering is now stable, so
47-
qpp::QCircuit measurement probabilities are not displayed in reversed order
48-
w.r.t. target
62+
- Bugfix in `qpp::internal::canonical_form()`, the re-ordering is now stable,
63+
so `qpp::QCircuit` measurement probabilities are not displayed in reversed
64+
order w.r.t. target
4965
- Simplified MATLAB detection via CMake `find_package()` function. Users should
5066
only use `-DQPP_MATLAB=ON` when building with MATLAB support, all other
5167
MATLAB-related CMake flags have been removed.
52-
- Added `read_from_string` to `qasm.hpp` and an associated pyqpp wrapper
68+
- Bugfix in `qpp::adjoint(QCircuit)`
69+
- Added `cond_func_t` type alias in ["qpp/types.hpp"] for boolean predicates of
70+
the form `std::vector<idx> -> bool`
71+
- Added `qpp::read_from_string()` to ["qpp/qasm/qasm.hpp"] and an associated
72+
pyqpp wrapper function
5373

5474
# Version 5.1 - 1 March 2024
5575

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.15)
2-
set(QPP_VERSION_NUM 5.1)
2+
set(QPP_VERSION_NUM 6.0)
33
set(QPP_VERSION_STR "${QPP_VERSION_NUM}")
44
project(
55
qpp
@@ -105,8 +105,10 @@ install(FILES "${CMAKE_SOURCE_DIR}/cmake/qpp_MATLAB.cmake"
105105

106106
# Uninstall
107107
# https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake
108-
# UNIX/Linux: sudo cmake --build build --target uninstall Windows: cmake
109-
# --build build --target uninstall
108+
#
109+
# UNIX/Linux: sudo cmake --build build --target uninstall
110+
111+
# Windows: cmake --build build --target uninstall
110112
if(NOT TARGET uninstall)
111113
configure_file(
112114
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/qpp_uninstall.cmake.in"

CODE_OF_CONDUCT.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ We as members, contributors, and leaders pledge to make participation in our
66
community a harassment-free experience for everyone, regardless of age, body
77
size, visible or invisible disability, ethnicity, sex characteristics, gender
88
identity and expression, level of experience, education, socio-economic status,
9-
nationality, personal appearance, race, caste, color, religion, or sexual identity
10-
and orientation.
9+
nationality, personal appearance, race, caste, color, religion, or sexual
10+
identity and orientation.
1111

1212
We pledge to act and interact in ways that contribute to an open, welcoming,
1313
diverse, inclusive, and healthy community.
@@ -22,17 +22,17 @@ community include:
2222
- Giving and gracefully accepting constructive feedback
2323
- Accepting responsibility and apologizing to those affected by our mistakes,
2424
and learning from the experience
25-
- Focusing on what is best not just for us as individuals, but for the
26-
overall community
25+
- Focusing on what is best not just for us as individuals, but for the overall
26+
community
2727

2828
Examples of unacceptable behavior include:
2929

30-
- The use of sexualized language or imagery, and sexual attention or
31-
advances of any kind
30+
- The use of sexualized language or imagery, and sexual attention or advances of
31+
any kind
3232
- Trolling, insulting or derogatory comments, and personal or political attacks
3333
- Public or private harassment
34-
- Publishing others' private information, such as a physical or email
35-
address, without their explicit permission
34+
- Publishing others' private information, such as a physical or email address,
35+
without their explicit permission
3636
- Other conduct which could reasonably be considered inappropriate in a
3737
professional setting
3838

@@ -52,7 +52,7 @@ decisions when appropriate.
5252

5353
This Code of Conduct applies within all community spaces, and also applies when
5454
an individual is officially representing the community in public spaces.
55-
Examples of representing our community include using an official e-mail address,
55+
Examples of representing our community include using an official email address,
5656
posting via an official social media account, or acting as an appointed
5757
representative at an online or offline event.
5858

@@ -81,15 +81,15 @@ behavior was inappropriate. A public apology may be requested.
8181

8282
### 2. Warning
8383

84-
**Community Impact**: A violation through a single incident or series
85-
of actions.
84+
**Community Impact**: A violation through a single incident or series of
85+
actions.
8686

8787
**Consequence**: A warning with consequences for continued behavior. No
8888
interaction with the people involved, including unsolicited interaction with
8989
those enforcing the Code of Conduct, for a specified period of time. This
9090
includes avoiding interactions in community spaces as well as external channels
91-
like social media. Violating these terms may lead to a temporary or
92-
permanent ban.
91+
like social media. Violating these terms may lead to a temporary or permanent
92+
ban.
9393

9494
### 3. Temporary Ban
9595

@@ -108,24 +108,24 @@ Violating these terms may lead to a permanent ban.
108108
standards, including sustained inappropriate behavior, harassment of an
109109
individual, or aggression toward or disparagement of classes of individuals.
110110

111-
**Consequence**: A permanent ban from any sort of public interaction within
112-
the community.
111+
**Consequence**: A permanent ban from any sort of public interaction within the
112+
community.
113113

114114
## Attribution
115115

116116
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
117-
version 2.0, available at
118-
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
117+
version 2.1, available at
118+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
119119

120120
Community Impact Guidelines were inspired by
121121
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
122122

123123
For answers to common questions about this code of conduct, see the FAQ at
124-
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
125-
at [https://www.contributor-covenant.org/translations][translations].
124+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
125+
[https://www.contributor-covenant.org/translations][translations].
126126

127127
[homepage]: https://www.contributor-covenant.org
128-
[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
128+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
129129
[Mozilla CoC]: https://github.com/mozilla/diversity
130130
[FAQ]: https://www.contributor-covenant.org/faq
131131
[translations]: https://www.contributor-covenant.org/translations

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ PROJECT_NAME = Quantum++
4848
# could be handy for archiving the generated documentation or if some version
4949
# control system is used.
5050

51-
PROJECT_NUMBER = v5.1
51+
PROJECT_NUMBER = v6.0
5252

5353
# Using the PROJECT_BRIEF tag one can provide an optional one line description
5454
# for a project that appears at the top of each page and should give viewer a

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2017 - 2024 softwareQ Inc. All rights reserved.
1+
Copyright (c) 2017 - 2025 softwareQ Inc. All rights reserved.
22

33
MIT License
44

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Quantum++
22

3-
## Version 5.1 - 1 March 2024
3+
## Version 6.0 - 14 April 2025
44

55
[![GitHub actions](https://github.com/softwareqinc/qpp/actions/workflows/cmake.yml/badge.svg)](https://github.com/softwareQinc/qpp/actions)
66

@@ -19,10 +19,7 @@ multiprocessing library.
1919
information processing tasks, being capable of simulating arbitrary quantum
2020
processes. The main design factors taken in consideration were the ease of use,
2121
high portability, and high performance. The library's simulation capabilities
22-
are only restricted by the amount of available physical memory. On a typical
23-
machine (Intel i5 8Gb RAM) **Quantum++** can successfully simulate the
24-
evolution of 25 qubits in a pure state or of 12 qubits in a mixed state
25-
reasonably fast.
22+
are only restricted by the amount of available physical memory.
2623

2724
To report any bugs or ask for additional features/enhancements, please
2825
[submit an issue](https://github.com/softwareQinc/qpp/issues) with an
@@ -43,7 +40,7 @@ see <https://eigen.tuxfamily.org/dox/>. For a simple
4340
[Eigen 3](https://eigen.tuxfamily.org) quick ASCII reference see
4441
<https://eigen.tuxfamily.org/dox/AsciiQuickReference.txt>.
4542

46-
Copyright (c) 2017 - 2024 softwareQ Inc. All rights reserved.
43+
Copyright (c) 2017 - 2025 softwareQ Inc. All rights reserved.
4744

4845
---
4946

VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Version 5.1 - 1 March 2024
1+
Version 6.0 - 14 April 2025

cmake/qpp_dependencies.cmake

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Quantum++ additional dependencies Do not modify unless you know what you're
2-
# doing
1+
# Quantum++ additional dependencies
2+
# Do not modify unless you know what you're doing
33

44
# Custom index type. If none selected, a default one is selected by
55
# include/types.hpp (usually std::size_t).
@@ -112,7 +112,7 @@ if(${QPP_OPENMP})
112112
find_package(OpenMP)
113113
if(OpenMP_CXX_FOUND)
114114
if(OpenMP_CXX_VERSION_MAJOR GREATER_EQUAL 3)
115-
# inject definition (as #define) in the source files
115+
# Inject definition (as #define) in the source files
116116
add_compile_definitions(QPP_OPENMP)
117117
# OpenMP linking dependencies to be injected in the main CMakeLists.txt
118118
set(QPP_OPENMP_LINK_DEPS OpenMP::OpenMP_CXX)
@@ -123,18 +123,20 @@ requires OpenMP 3.0 or later")
123123
endif()
124124
endif()
125125

126-
# Disable support for thread_local storage duration specifier when using
127-
# AppleClang as libc++ doesn't yet support it if (${CMAKE_CXX_COMPILER_ID}
128-
# STREQUAL "AppleClang") #### inject definition (as #define) in the source files
129-
# add_definitions(-DNO_THREAD_LOCAL_) message(WARNING "Detected compiler:
130-
# ${CMAKE_CXX_COMPILER_ID} \ ${CMAKE_CXX_COMPILER_VERSION}. thread_local not
131-
# supported.") endif ()
126+
# # Disable support for thread_local storage duration specifier when using
127+
# # AppleClang as libc++ doesn't yet support it
128+
# if (${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang")
129+
# # Inject definition (as #define) in the source files
130+
# add_definitions(-DNO_THREAD_LOCAL_)
131+
# message(WARNING "Detected compiler: ${CMAKE_CXX_COMPILER_ID} \
132+
# ${CMAKE_CXX_COMPILER_VERSION}. thread_local not # supported.")
133+
# endif ()
132134

133135
# Windows issues with Microsoft Visual Studio
134136
if(MSVC)
135137
# Disable spurious Eigen warnings with MSVC (warning STL4007)
136138
add_compile_definitions(_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING)
137-
add_compile_options(-bigobj)
139+
add_compile_options(/bigobj)
138140
endif()
139141

140142
# MinGW or Cygwin have issues with object files that are too large
@@ -154,11 +156,12 @@ endif()
154156

155157
# GCC additional debug settings
156158
if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
157-
# if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") ## use the "no-weak" debugging
158-
# flag only when debugging under OS X, ## as gdb cannot step in template
159-
# functions when debugging code ## produced by g++ ## see
160-
# https://stackoverflow.com/questions/23330641/gnu-gdb-can-not-step-into-template-functions-os-x-mavericks
161-
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-weak") endif ()
159+
# if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
160+
# # Use the "no-weak" debugging flag only when debugging under OS X, as gdb
161+
# # cannot step in template functions when debugging code produced by g++, see
162+
# # https://stackoverflow.com/questions/23330641/gnu-gdb-can-not-step-into-template-functions-os-x-mavericks
163+
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-weak")
164+
# endif ()
162165
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -D_GLIBCXX_DEBUG")
163166
endif()
164167

0 commit comments

Comments
 (0)