From 6062a751175824ff2ae700ce39d6228f36be4d92 Mon Sep 17 00:00:00 2001 From: Lee James O'Riordan Date: Tue, 8 Oct 2024 16:48:15 -0400 Subject: [PATCH] Ensure inline templated func hit with arith types only (#936) ### Before submitting Please complete the following checklist when submitting a PR: - [x] All new features must include a unit test. If you've fixed a bug or added code that should be tested, add a test to the [`tests`](../tests) directory! - [x] All new functions and code must be clearly commented and documented. If you do make documentation changes, make sure that the docs build and render correctly by running `make docs`. - [x] Ensure that the test suite passes, by running `make test`. - [x] Add a new entry to the `.github/CHANGELOG.md` file, summarizing the change, and including a link back to the PR. - [x] Ensure that code is properly formatted by running `make format`. When all the above are checked, delete everything above the dashed line and fill in the pull request template. ------------------------------------------------------------------------------------------------------------ **Context:** Closes https://github.com/PennyLaneAI/pennylane-lightning/issues/935 **Description of the Change:** Adds concept restrictions to the `ConstMult` function definition for scalar-time-complex only instantiations. **Benefits:** Removes the given build failure. **Possible Drawbacks:** **Related GitHub Issues:** --------- Co-authored-by: ringo-but-quantum Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com> --- .github/CHANGELOG.md | 3 +++ pennylane_lightning/core/_version.py | 2 +- pennylane_lightning/core/src/utils/Util.hpp | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 27ecd62a7f..95e18a73f2 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -110,6 +110,9 @@ ### Bug fixes +* Add concept restriction to ensure `ConstMult` inline function only hit with arithmetic-values times complex values. Fixes build failures with the test suite when enabling OpenMP, and disabling BLAS and Python under clang. + [(#936)](https://github.com/PennyLaneAI/pennylane-lightning/pull/936) + * Bug fix for `applyMatrix` in `lightning.tensor`. Matrix operator data is not stored in the `cuGateCache` object to support `TensorProd` obs with multiple `Hermitian` obs. [(#932)](https://github.com/PennyLaneAI/pennylane-lightning/pull/932) diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py index c6e0b5050a..ab5a1f0f5d 100644 --- a/pennylane_lightning/core/_version.py +++ b/pennylane_lightning/core/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.39.0-dev40" +__version__ = "0.39.0-dev41" diff --git a/pennylane_lightning/core/src/utils/Util.hpp b/pennylane_lightning/core/src/utils/Util.hpp index e0d3a1170e..5544c96ba9 100644 --- a/pennylane_lightning/core/src/utils/Util.hpp +++ b/pennylane_lightning/core/src/utils/Util.hpp @@ -26,6 +26,7 @@ #include #include // is_same_v #include +#include // integral, floating_point #include "Error.hpp" #include "TypeTraits.hpp" // remove_complex_t @@ -41,6 +42,7 @@ namespace Pennylane::Util { * @return constexpr std::complex */ template + requires std::integral || std::floating_point inline static constexpr auto ConstMult(U a, std::complex b) -> std::complex { return {a * b.real(), a * b.imag()};