39 if (field.
empty() || !(resolution > 0.0) || !std::isfinite(resolution) ||
48 const std::vector<PositionMeasurement2DPoint> latent =
54 std::mt19937 engine(seed ^ 0x9e3779b9u);
55 std::normal_distribution<double> noise(0.0, resolution);
56 result.
outcome.
x =
static_cast<float>(
static_cast<double>(latent.front().x) + noise(engine));
57 result.
outcome.
y =
static_cast<float>(
static_cast<double>(latent.front().y) + noise(engine));
59 const double invFourSigma2 = 1.0 / (4.0 * resolution * resolution);
60 for (std::size_t y = 0u; y < field.
height(); ++y) {
62 const double dy = py -
static_cast<double>(result.
outcome.
y);
63 for (std::size_t x = 0u; x < field.
width(); ++x) {
65 const double dx = px -
static_cast<double>(result.
outcome.
x);
66 const double exponent = -(dx * dx + dy * dy) * invFourSigma2;
67 const float weight =
static_cast<float>(std::exp(exponent));
68 field(x, y) *= weight;
86 std::random_device rd;
87 std::seed_seq seedSequence{rd(), rd(), rd(), rd(),
88 static_cast<unsigned int>(field.
width()),
89 static_cast<unsigned int>(field.
height())};
90 std::uint32_t seed = 0u;
91 seedSequence.generate(&seed, &seed + 1);
92 return collapseWithSeed(field, resolution, seed);
99 return collapseWithSeed(field, resolution, seed);
Owning Cartesian grid of complex scalar samples.
double norm2() const noexcept
Returns the discrete integral of |psi|^2 including dx*dy.
bool empty() const noexcept
Returns whether the field contains no samples.
std::size_t height() const noexcept
Returns the number of samples along Y.
bool normalize() noexcept
Scales the field to unit discrete probability norm.
std::size_t width() const noexcept
Returns the number of samples along X.
static double yCoordinate(const ComplexField2D &field, std::size_t y) noexcept
Performs y coordinate.
static double xCoordinate(const ComplexField2D &field, std::size_t x) noexcept
Performs x coordinate.
static PositionCollapse2DResult collapse(ComplexField2D &field, double resolution)
Performs collapse.
static PositionCollapse2DResult collapseSeeded(ComplexField2D &field, double resolution, std::uint32_t seed)
Performs collapse seeded.
static std::vector< PositionMeasurement2DPoint > sampleSeeded(const ComplexField2D &field, std::size_t shots, std::uint32_t seed)
Samples seeded.
Declares the complex scalar field container representing two-dimensional wave functions.
Declares the gaussianpacket2d physics/numerical component used by QPE experiments.
PositionCollapse2DResult collapseWithSeed(ComplexField2D &field, double resolution, std::uint32_t seed)
Performs collapse with seed.
Declares the positioncollapse2d physics/numerical component used by QPE experiments.
Declares the positionmeasurement2d physics/numerical component used by QPE experiments.
Data record containing Position Collapse2D Result.
PositionMeasurement2DPoint outcome