Skip to content

Commit

Permalink
[feature/CI_setup] tracking down CI test failures that I can't reprod…
Browse files Browse the repository at this point in the history
…uce locally
  • Loading branch information
jamesETsmith committed Jun 7, 2024
1 parent 0db7415 commit 34f8da0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

## Requirements

- CMake >= 3.20
- CMake >= 3.25
- C++ compiler with OpenMP and C++20 support (LLVM recommended)
- Tested Compilers GCC@12, LLVM@17, LLVM@18
- Python >= 3.10
Expand Down
12 changes: 6 additions & 6 deletions include/__pauli_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ template <std::floating_point T> struct PauliOp {
// possible combinations up to and including weight 3 strings?)
std::vector<PauliString> pauli_strings;

constexpr PauliOp() = default;
PauliOp() = default;

//
constexpr PauliOp(std::vector<std::complex<T>> const &coeffs,
std::vector<PauliString> const &pauli_strings)
PauliOp(std::vector<std::complex<T>> const &coeffs,
std::vector<PauliString> const &pauli_strings)
: coeffs(coeffs), pauli_strings(pauli_strings) {
// TODO may want to wrap this in a #IFDEF DEBUG block to avoid the overhead
// input check
Expand All @@ -44,15 +44,15 @@ template <std::floating_point T> struct PauliOp {
}
}

constexpr size_t dims() const {
size_t dims() const {
if (pauli_strings.size() > 0) {
return pauli_strings[0].dims();
} else {
return 0;
}
}

constexpr std::vector<std::complex<T>>
std::vector<std::complex<T>>
apply(std::vector<std::complex<T>> const &state) const {
// input check
if (state.size() != dims()) {
Expand Down Expand Up @@ -170,7 +170,7 @@ template <std::floating_point T> struct PauliOp {
//
// Helpers (mostly for debugging)
//
constexpr std::vector<std::vector<std::complex<T>>> get_dense_repr() const {
std::vector<std::vector<std::complex<T>>> get_dense_repr() const {
size_t const dim = 1UL << pauli_strings[0].paulis.size();

std::vector<std::vector<std::complex<T>>> res(
Expand Down
18 changes: 8 additions & 10 deletions include/__summed_pauli_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ template <std::floating_point T> struct SummedPauliOp {
size_t _dim;
size_t _n_operators;

constexpr SummedPauliOp() noexcept = default;
SummedPauliOp() noexcept = default;

//
constexpr SummedPauliOp(std::vector<PauliString> const &pauli_strings,
std::vector<std::complex<T>> const &coeffs_raw)
SummedPauliOp(std::vector<PauliString> const &pauli_strings,
std::vector<std::complex<T>> const &coeffs_raw)
: pauli_strings(pauli_strings), coeffs_raw(coeffs_raw) {

// TODO add more checks
Expand All @@ -47,8 +47,8 @@ template <std::floating_point T> struct SummedPauliOp {
}
}

constexpr SummedPauliOp(std::vector<PauliString> const &pauli_strings,
Tensor<2> const coeffs)
SummedPauliOp(std::vector<PauliString> const &pauli_strings,
Tensor<2> const coeffs)
: pauli_strings(pauli_strings) {

// Check that the dims are all the same
Expand Down Expand Up @@ -77,11 +77,9 @@ template <std::floating_point T> struct SummedPauliOp {
//
// Accessors/helpers
//
constexpr size_t n_dimensions() const noexcept { return _dim; }
constexpr size_t n_operators() const noexcept { return _n_operators; }
constexpr size_t n_pauli_strings() const noexcept {
return pauli_strings.size();
}
size_t n_dimensions() const noexcept { return _dim; }
size_t n_operators() const noexcept { return _n_operators; }
size_t n_pauli_strings() const noexcept { return pauli_strings.size(); }

//
// Primary (TODO "primary" is vague here) functions
Expand Down
2 changes: 2 additions & 0 deletions tests/test_pauli_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ TEST_CASE("test apply multistate multistring") {
// Check
for (size_t t = 0; t < n_states; ++t) {
for (size_t i = 0; i < dims; ++i) {
fmt::println("new_states(i, t): {}, expected_span(i, t): {}",
new_states(i, t), expected_span(i, t));
CHECK(abs(new_states(i, t) - expected_span(i, t)) < 1e-6);
}
}
Expand Down

0 comments on commit 34f8da0

Please sign in to comment.