From 2575f07a86680e557f9f5620dbbc5ae71fe3d347 Mon Sep 17 00:00:00 2001 From: jamesETsmith Date: Thu, 6 Jun 2024 14:43:43 -0400 Subject: [PATCH] [feature/CI_setup] Cleaning up problems from other compilers --- .gitignore | 1 + CMakeLists.txt | 6 ++--- include/__factory.hpp | 1 + include/__pauli.hpp | 3 --- include/__pauli_string.hpp | 50 ++++++++++++++++++-------------------- 5 files changed, 27 insertions(+), 34 deletions(-) diff --git a/.gitignore b/.gitignore index bd3e442..aaf460a 100644 --- a/.gitignore +++ b/.gitignore @@ -79,3 +79,4 @@ __pycache__ logs scratch notes +.cache diff --git a/CMakeLists.txt b/CMakeLists.txt index 20652c1..da23646 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,6 @@ include(cmake/CPM.cmake) # Dependencies cpmaddpackage("gh:doctest/doctest@2.4.11") -# cpmaddpackage("gh:p-ranav/argparse@3.0") cpmaddpackage("gh:pybind/pybind11@2.11.1") cpmaddpackage("gh:fmtlib/fmt#10.2.1") cpmaddpackage("gh:kokkos/mdspan#b885a2c60ad42f9e1aaa0d317a38105b950cbed0") @@ -62,9 +61,8 @@ target_compile_options( -Werror # -stdlib=libc++ ${FAST_PAULI_EXTRA_CXX_COMPILE_FLAGS}) -target_link_options(fast_pauli INTERFACE ${FAST_PAULI_EXTRA_CXX_LD_FLAGS} - -fuse-ld=mold) -# target_compile_definitions(fast_pauli INTERFACE) +# target_link_options(fast_pauli INTERFACE ${FAST_PAULI_EXTRA_CXX_LD_FLAGS} +# -fuse-ld=mold) target_compile_definitions(fast_pauli INTERFACE) # Testing include(CTest) diff --git a/include/__factory.hpp b/include/__factory.hpp index 7e7469f..51f08b7 100644 --- a/include/__factory.hpp +++ b/include/__factory.hpp @@ -1,6 +1,7 @@ #ifndef __FAST_PAULI_FACTORY_HPP #define __FAST_PAULI_FACTORY_HPP +#include #include #include #include diff --git a/include/__pauli.hpp b/include/__pauli.hpp index 1c01443..eacdcc2 100644 --- a/include/__pauli.hpp +++ b/include/__pauli.hpp @@ -160,7 +160,6 @@ struct Pauli { } // namespace fast_pauli // Adding specialization to the fmt library so we can easily print Pauli -namespace fmt { template <> struct fmt::formatter { constexpr auto parse(format_parse_context &ctx) { return ctx.begin(); } @@ -199,6 +198,4 @@ template <> struct fmt::formatter> { } }; -} // namespace fmt - #endif // __PAULI_HPP diff --git a/include/__pauli_string.hpp b/include/__pauli_string.hpp index 4f59038..e3570d6 100644 --- a/include/__pauli_string.hpp +++ b/include/__pauli_string.hpp @@ -32,14 +32,14 @@ struct PauliString { * @brief Default constructor, initialize weight and empty vector for paulis. * */ - constexpr PauliString() noexcept = default; + PauliString() noexcept = default; /** * @brief Constructs a PauliString from a span of pauli operators and * calculates the weight. * */ - constexpr PauliString(std::span const &paulis) + PauliString(std::span const &paulis) : weight(0), paulis(paulis.begin(), paulis.end()) { for (auto const &pauli : paulis) { weight += pauli.code > 0; @@ -51,7 +51,7 @@ struct PauliString { * This is often the most compact way to initialize a PauliString. * */ - constexpr PauliString(std::string const &str) : weight(0) { + PauliString(std::string const &str) : weight(0) { for (auto const &c : str) { switch (c) { case 'I': @@ -81,11 +81,11 @@ struct PauliString { * @brief * */ - constexpr PauliString(char const *str) : PauliString(std::string(str)) {} + PauliString(char const *str) : PauliString(std::string(str)) {} - constexpr PauliString(PauliString const &other) + PauliString(PauliString const &other) : weight(other.weight), paulis(other.paulis){}; - constexpr PauliString &operator=(PauliString const &other) { + PauliString &operator=(PauliString const &other) { this->weight = other.weight; this->paulis = other.paulis; return *this; @@ -98,16 +98,16 @@ struct PauliString { /** * @brief Return the number of qubits in the PauliString. * - * @return constexpr size_t + * @return size_t */ - constexpr size_t n_qubits() const noexcept { return paulis.size(); } + size_t n_qubits() const noexcept { return paulis.size(); } /** * @brief Return the dimension (2^n_qubits) of the PauliString. * - * @return constexpr size_t + * @return size_t */ - constexpr size_t dims() const noexcept { return 1UL << paulis.size(); } + size_t dims() const noexcept { return 1UL << paulis.size(); } /** * @brief Get the sparse representation of the pauli string matrix. @@ -126,8 +126,8 @@ struct PauliString { * @param m The values of the matrix */ template - constexpr void get_sparse_repr(std::vector &j, std::vector &k, - std::vector> &m) const { + void get_sparse_repr(std::vector &j, std::vector &k, + std::vector> &m) const { // We reverse the view here because the tensor product is taken from right // to left auto ps = paulis | std::views::reverse; @@ -184,11 +184,11 @@ struct PauliString { * @tparam T The floating point base to use for all the complex numbers * @param v The input vector to apply the PauliString to. Must be the same * size as PauliString.dims(). - * @return constexpr std::vector> The output state after + * @return std::vector> The output state after * applying the PauliString. */ template - constexpr std::vector> + std::vector> apply(std::vector> const &v) const { // Input check if (v.size() != dims()) { @@ -214,11 +214,11 @@ struct PauliString { * @tparam T The floating point base to use for all the complex numbers * @param v The input vector to apply the PauliString to. Must be the same * size as PauliString.dims(). - * @return constexpr std::vector> The output state after + * @return std::vector> The output state after * applying the PauliString. */ template - constexpr std::vector> + std::vector> apply(std::mdspan, std::dextents> v) const { // Input check if (v.size() != dims()) { @@ -251,12 +251,11 @@ struct PauliString { * @param c Multiplication factor to apply to the PauliString */ template - constexpr void - apply_batch(std::mdspan, std::dextents> - new_states_T, // extent(0) = dims, extent(1) = n_states - std::mdspan, std::dextents> const - states_T, // extent(0) = dims, extent(1) = n_states - std::complex const c) const { + void apply_batch(std::mdspan, std::dextents> + new_states_T, // extent(0) = dims, extent(1) = n_states + std::mdspan, std::dextents> const + states_T, // extent(0) = dims, extent(1) = n_states + std::complex const c) const { // Input check if (states_T.extent(0) != dims()) { auto error_msg = @@ -297,10 +296,10 @@ struct PauliString { * @brief Get the dense representation of the object as a 2D-std::vector * * @tparam T The floating point base to use for all the complex numbers - * @return constexpr std::vector>> + * @return std::vector>> */ template - constexpr std::vector>> get_dense_repr() const { + std::vector>> get_dense_repr() const { // std::vector j, k; std::vector> m; @@ -450,7 +449,6 @@ std::vector calculate_pauli_strings_max_weight(size_t n_qubits, // fmt::formatter specialization // -namespace fmt { // template <> struct fmt::formatter { constexpr auto parse(format_parse_context &ctx) { return ctx.begin(); } @@ -462,6 +460,4 @@ template <> struct fmt::formatter { } }; -} // namespace fmt - #endif // __PAULI_STRING_HPP