Skip to content

Commit

Permalink
Minor cosmetics in cpp files
Browse files Browse the repository at this point in the history
  • Loading branch information
stand-by committed Jul 30, 2024
1 parent 99e5ccd commit 32d59ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fast_pauli/cpp/include/__pauli_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ struct PauliString {
*/
template <std::floating_point T>
std::vector<std::complex<T>>
apply(std::mdspan<const std::complex<T>, std::dextents<size_t, 1>> v) const {
apply(std::mdspan<std::complex<T> const, std::dextents<size_t, 1>> v) const {
// Input check
if (v.size() != dims()) {
throw std::invalid_argument(
Expand Down
7 changes: 5 additions & 2 deletions fast_pauli/cpp/src/fast_pauli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ PYBIND11_MODULE(_fast_pauli, m) {
[](fp::PauliString const &self,
std::vector<std::vector<std::complex<double>>> inputs,
std::complex<double> coef) {
if (inputs.empty())
return std::vector<std::vector<std::complex<double>>>{};
// for now we expect row major inputs which have states as columns
const size_t n_states = inputs[0].size();
size_t const n_states = inputs.front().size();
std::vector<std::complex<double>> flat_inputs;
flat_inputs.reserve(inputs.size() * n_states);

for (const auto &vec : inputs)
for (auto const &vec : inputs)
if (vec.size() != n_states)
throw std::invalid_argument("Bad shape of states array");
else
Expand All @@ -66,6 +68,7 @@ PYBIND11_MODULE(_fast_pauli, m) {
flat_inputs.data(), inputs.size(), n_states},
coef);

// TODO arrange this ugly converters into utility functions at least
std::vector<std::vector<std::complex<double>>> results(
inputs.size());
for (size_t i = 0; i < inputs.size(); i++) {
Expand Down

0 comments on commit 32d59ba

Please sign in to comment.