diff --git a/Detector.h b/Detector.h new file mode 100644 index 0000000..1a122df --- /dev/null +++ b/Detector.h @@ -0,0 +1,56 @@ +#pragma once + +#include "Random.h" + +#include +#include +#include +#include +#include + +// Fast Poisson sampling (avoid std::poisson_distribution, which is slow to +// construct for each sample of different lambda). +// - For small lambda: Knuth DE, The Art of Computer Programming, Volume 2: +// Seminumerical Algorithms, 3rd ed, section 3.4.1.F.3. +// - For large lambda: Gaussian approximation N(lambda, sqrt(lambda)) +template +F FastPoisson(F lambda, RNG &rng, + rnd::uniform_real_distribution &uniformDist) { + if (lambda > F(10.0)) { + rnd::normal_distribution gaussianDist(lambda, std::sqrt(lambda)); + return std::max(F(0), gaussianDist(rng)); + } else { + F const L = std::exp(-lambda); + F p = 1.0; + int k = 0; + do { + ++k; + p *= uniformDist(rng); + } while (p > L); + return static_cast(k - 1); + } +} + +// Simulates sensor readout. signal is the expected photoelectron count per +// pixel, or nullptr for no light. Applies shot noise (to signal), read noise, +// and offset, then rounds and clamps to the pixel range. +template +void ReadOut(const float *signal, std::uint16_t *out, std::size_t nPixels, + float readNoise, float offset, RNG &rng) { + const bool hasReadNoise = readNoise > 0.0f; + rnd::normal_distribution readNoiseDistrib( + 0.0f, hasReadNoise ? readNoise : 1.0f); + rnd::uniform_real_distribution uniformDistForPoisson(0.0f, 1.0f); + const float maxVal = float(std::numeric_limits::max()); + for (std::size_t i = 0; i < nPixels; ++i) { + float v = offset; + if (hasReadNoise) { + v += readNoiseDistrib(rng); + } + if (signal && signal[i] > 0.0f) { + v += FastPoisson(signal[i], rng, uniformDistForPoisson); + } + out[i] = static_cast( + std::clamp(std::round(v), 0.0f, maxVal)); + } +} diff --git a/DeviceAdapter.cpp b/DeviceAdapter.cpp index 2e2678f..14b0e79 100644 --- a/DeviceAdapter.cpp +++ b/DeviceAdapter.cpp @@ -2,6 +2,7 @@ #include "SimFocus.h" #include "SimHub.h" #include "SimObjectiveTurret.h" +#include "SimShutter.h" #include "SimXY.h" #include "DeviceBase.h" @@ -31,6 +32,9 @@ MODULE_API MM::Device *CreateDevice(const char *name) { if (n == "SimObjectiveTurret") { return new SimObjectiveTurret("SimObjectiveTurret"); } + if (n == "SimShutter") { + return new SimShutter("SimShutter"); + } return nullptr; } diff --git a/Random.h b/Random.h new file mode 100644 index 0000000..1163c37 --- /dev/null +++ b/Random.h @@ -0,0 +1,9 @@ +#pragma once + +#ifdef USE_BOOST_RANDOM +#include +namespace rnd = boost::random; +#else +#include +namespace rnd = std; +#endif diff --git a/SimCam.h b/SimCam.h index e3eb7cd..dbcc36f 100644 --- a/SimCam.h +++ b/SimCam.h @@ -1,18 +1,23 @@ #pragma once +#include "Detector.h" #include "SimHub.h" #include "Specimen.h" #include "DeviceBase.h" +#include #include #include +#include #include #include +#include #include #include #include #include +#include // In C++17 can make static constexpr member of SimCam constexpr double EXPOSURE_MS_MIN = 0.001; @@ -27,8 +32,8 @@ class SimCam : public CCameraBase { static constexpr const char *modeFilaments_ = "Filaments"; static constexpr const char *modeNuclei_ = "Nuclei"; - FilamentsSpecimen filamentsSpecimen_; - NucleiSpecimen nucleiSpecimen_; + FilamentsSpecimen filamentsSpecimen_; + NucleiSpecimen nucleiSpecimen_; std::string mode_ = modeFilaments_; // Camera state @@ -41,6 +46,9 @@ class SimCam : public CCameraBase { // Last snap (always equal to ROI width/height) std::unique_ptr snapBuffer_; + std::vector signal_; + rnd::mt19937 rng_; + // Sequence acquisition state std::thread seqThread_; std::mutex seqMutex_; @@ -139,13 +147,23 @@ class SimCam : public CCameraBase { const double intensity = 2800.0 * GetExposure() * GetBinning() * GetBinning() * (na * na * na * na) / (magnification * magnification); - if (mode_ == modeNuclei_) { - nucleiSpecimen_.Draw(snapBuffer_.get(), x, y, z, roiWidth_, - roiHeight_, umPerPx, na, intensity); - } else { - filamentsSpecimen_.Draw(snapBuffer_.get(), x, y, z, roiWidth_, - roiHeight_, umPerPx, na, intensity); + const float *signal = nullptr; + if (hub->IsShutterOpen()) { + signal_.resize(nPixels); + if (mode_ == modeNuclei_) { + nucleiSpecimen_.Draw(signal_.data(), x, y, z, roiWidth_, + roiHeight_, umPerPx, na, intensity); + } else { + filamentsSpecimen_.Draw(signal_.data(), x, y, z, roiWidth_, + roiHeight_, umPerPx, na, intensity); + } + signal = signal_.data(); } + // TODO: Make read noise and offset adjustable? + constexpr float readNoise = 50.0f; + constexpr float darkOffset = 100.0f; + ReadOut(signal, snapBuffer_.get(), nPixels, readNoise, darkOffset, + rng_); std::chrono::duration exposure(GetExposure()); const auto finishTime = diff --git a/SimHub.cpp b/SimHub.cpp index c4d0a67..5fb4379 100644 --- a/SimHub.cpp +++ b/SimHub.cpp @@ -3,6 +3,7 @@ #include "SimCam.h" #include "SimFocus.h" #include "SimObjectiveTurret.h" +#include "SimShutter.h" #include "SimXY.h" int SimHub::DetectInstalledDevices() { @@ -11,5 +12,6 @@ int SimHub::DetectInstalledDevices() { AddInstalledDevice(new SimFocus>("SimFocus")); AddInstalledDevice(new SimObjectiveTurret("SimObjectiveTurret")); AddInstalledDevice(new SimXY>("SimXY")); + AddInstalledDevice(new SimShutter("SimShutter")); return DEVICE_OK; -} \ No newline at end of file +} diff --git a/SimHub.h b/SimHub.h index 8070936..9690be2 100644 --- a/SimHub.h +++ b/SimHub.h @@ -15,6 +15,7 @@ class SimHub : public HubBase { }; std::function getMagnificationFunc_ = [] { return 1.0; }; std::function getNAFunc_ = [] { return 1.0; }; + std::function getShutterOpenFunc_ = [] { return true; }; public: explicit SimHub(std::string name) : name_(std::move(name)) {} @@ -39,8 +40,13 @@ class SimHub : public HubBase { template void SetGetNAFunction(F f) { getNAFunc_ = f; } + template void SetGetShutterOpenFunction(F f) { + getShutterOpenFunc_ = f; + } + double GetFocusUm() { return getFocusUmFunc_(); } std::pair GetXYUm() { return getXYUmFunc_(); } double GetMagnification() { return getMagnificationFunc_(); } double GetNA() { return getNAFunc_(); } -}; \ No newline at end of file + bool IsShutterOpen() { return getShutterOpenFunc_(); } +}; diff --git a/SimShutter.h b/SimShutter.h new file mode 100644 index 0000000..857acb9 --- /dev/null +++ b/SimShutter.h @@ -0,0 +1,84 @@ +#pragma once + +#include "SimHub.h" + +#include "DeviceBase.h" + +#include +#include +#include + +class SimShutter : public CShutterBase { + std::string name_; + bool initialized_ = false; + + // Shutter state + std::atomic isOpen_{false}; + + public: + explicit SimShutter(std::string name) : name_(std::move(name)) {} + + ~SimShutter() { Shutdown(); } + + bool Busy() final { + // TODO: Could introduce a small delay here + return false; + } + + void GetName(char *name) const final { + CDeviceUtils::CopyLimitedString(name, name_.c_str()); + } + + int Fire(double /*deltaT*/) final { return DEVICE_UNSUPPORTED_COMMAND; } + + int Initialize() final { + isOpen_ = false; + + int ret = CreateIntegerProperty( + MM::g_Keyword_State, 0, false, + new MM::ActionLambda( + [this](MM::PropertyBase *pProp, MM::ActionType eAct) { + if (eAct == MM::BeforeGet) { + pProp->Set(isOpen_ ? 1L : 0L); + } else if (eAct == MM::AfterSet) { + long v{}; + pProp->Get(v); + return SetOpen(v != 0); + } + return DEVICE_OK; + })); + if (ret != DEVICE_OK) + return ret; + ret = AddAllowedValue(MM::g_Keyword_State, "0"); + if (ret != DEVICE_OK) + return ret; + ret = AddAllowedValue(MM::g_Keyword_State, "1"); + if (ret != DEVICE_OK) + return ret; + + auto *hub = static_cast(GetParentHub()); + hub->SetGetShutterOpenFunction([this] { return isOpen_.load(); }); + initialized_ = true; + return DEVICE_OK; + } + + int Shutdown() final { + isOpen_ = false; + if (initialized_) { + auto *hub = static_cast(GetParentHub()); + hub->SetGetShutterOpenFunction([] { return true; }); + initialized_ = false; + } + return DEVICE_OK; + } + + int SetOpen(bool open = true) final { + isOpen_ = open; + return DEVICE_OK; + } + + int GetOpen(bool &open) final { + open = isOpen_; + return DEVICE_OK; + } +}; diff --git a/Specimen.h b/Specimen.h index 024c3de..9fd89f9 100644 --- a/Specimen.h +++ b/Specimen.h @@ -1,24 +1,16 @@ #pragma once #include "Gaussian2DFilter.h" +#include "Random.h" #include #include #include #include -#include #include #include -#ifdef USE_BOOST_RANDOM -#include -namespace rnd = boost::random; -#else -#include -namespace rnd = std; -#endif - constexpr double PI = 3.1415926535897; template @@ -30,40 +22,17 @@ inline F GaussianSigmaForDefocus(F defocus_um, F numericalAperture, return F(0.5) * radius + F(1.0); } -// Fast Poisson sampling (avoid std::poisson_distribution, which is slow to -// construct for each sample of different lambda). -// - For small lambda: Knuth DE, The Art of Computer Programming, Volume 2: -// Seminumerical Algorithms, 3rd ed, section 3.4.1.F.3. -// - For large lambda: Gaussian approximation N(lambda, sqrt(lambda)) -template -F FastPoisson(F lambda, RNG &rng, - rnd::uniform_real_distribution &uniformDist) { - if (lambda > F(10.0)) { - rnd::normal_distribution gaussianDist(lambda, std::sqrt(lambda)); - return std::max(F(0), gaussianDist(rng)); - } else { - F const L = std::exp(-lambda); - F p = 1.0; - int k = 0; - do { - ++k; - p *= uniformDist(rng); - } while (p > L); - return static_cast(k - 1); - } -} - -// Renders a specimen image: sets up the blend2d canvas (scaled/translated to -// specimen space and marked with an origin cross), invokes drawContent(ctx) -// to paint the specimen-specific structure, then applies the shared -// defocus blur, intensity scaling, and shot/read noise pipeline common to -// all simulated specimens. rng is used for the noise (and may also be used -// by drawContent). -template -void RenderSpecimenImage(T *buffer, double x_um, double y_um, double z_um, +// Renders the expected (noise-free) signal of a specimen into signal (width * +// height floats), overwriting it: sets up the blend2d canvas +// (scaled/translated to specimen space and marked with an origin cross), +// invokes drawContent(ctx) to paint the specimen-specific structure, then +// applies the defocus blur and intensity scaling common to all simulated +// specimens. +template +void RenderSpecimenImage(float *signal, double x_um, double y_um, double z_um, std::size_t width, std::size_t height, double um_per_px, double na, double intensity, - rnd::mt19937 &rng, ContentFn &&drawContent) { + ContentFn &&drawContent) { BLImage img(static_cast(width), static_cast(height), BL_FORMAT_XRGB32); BLContext ctx(img); @@ -82,24 +51,25 @@ void RenderSpecimenImage(T *buffer, double x_um, double y_um, double z_um, ctx.end(); + const std::size_t nPixels = width * height; + BLImageData data; BLResult status = img.getData(&data); if (status != BL_SUCCESS) { - std::memset(buffer, 0, sizeof(T) * width * height); + std::fill(signal, signal + nPixels, 0.0f); return; // Give up (shouldn't happen). } const auto *pix = static_cast(data.pixelData); // Stride is the stride of scanlines; negative stride means bottom-up. - std::vector fImage(width * height); const std::intptr_t stride = data.stride / sizeof(std::uint32_t); const std::intptr_t start = stride >= 0 ? 0 : (height - 1) * (-stride); for (std::intptr_t j = 0; j < std::intptr_t(height); ++j) { for (std::intptr_t i = 0; i < std::intptr_t(width); ++i) { const auto p = pix[start + i + j * stride]; // Green sample - fImage[i + j * width] = static_cast((p >> 8) & 0xff); + signal[i + j * width] = static_cast((p >> 8) & 0xff); } } @@ -107,66 +77,45 @@ void RenderSpecimenImage(T *buffer, double x_um, double y_um, double z_um, const auto sigmaUm = GaussianSigmaForDefocus(float(z_um), float(na), 1.33f); const auto sigmaPixels = sigmaUm / float(um_per_px); - FastGaussian2D(fImage.data(), width, height, sigmaPixels); + FastGaussian2D(signal, width, height, sigmaPixels); // Scale by intensity - std::transform(fImage.begin(), fImage.end(), fImage.begin(), + std::transform(signal, signal + nPixels, signal, [i = float(intensity)](float p) { return p * i; }); - - // Shot noise - auto uniformDistForPoisson = - rnd::uniform_real_distribution(0.0, 1.0); - std::transform(fImage.begin(), fImage.end(), fImage.begin(), [&](float p) { - return p > 0.0f ? FastPoisson(p, rng, uniformDistForPoisson) : p; - }); - - // Gaussian (~read) noise (TODO Adjustable? Scale?) - // and dark offset (TODO adjustable?) - auto noiseDistrib = rnd::normal_distribution(0.0, 50.0); - const float darkOffset = 100.0f; - std::transform(fImage.begin(), fImage.end(), fImage.begin(), [&](float p) { - return p + noiseDistrib(rng) + darkOffset; - }); - - // Clamp to pixel type range - std::transform(fImage.begin(), fImage.end(), buffer, [](float v) { - return static_cast(std::clamp( - std::round(v), 0.0f, float(std::numeric_limits::max()))); - }); } -template class FilamentsSpecimen { +class FilamentsSpecimen { struct Filament { double x0, y0, x1, y1; }; - rnd::mt19937 rng_; std::vector filaments_; public: explicit FilamentsSpecimen() { using std::cos; using std::sin; + rnd::mt19937 rng; rnd::normal_distribution<> xy0Distrib(0.0, 1000.0); rnd::uniform_real_distribution<> thetaDistrib(0.0, 2.0 * PI); rnd::exponential_distribution<> lenDistrib(1e-3); for (int i = 0; i < 1000; ++i) { - const double x0 = xy0Distrib(rng_); - const double y0 = xy0Distrib(rng_); - const double theta = thetaDistrib(rng_); - const double len = lenDistrib(rng_); + const double x0 = xy0Distrib(rng); + const double y0 = xy0Distrib(rng); + const double theta = thetaDistrib(rng); + const double len = lenDistrib(rng); const double x1 = x0 + len * cos(theta); const double y1 = y0 + len * sin(theta); filaments_.push_back({x0, y0, x1, y1}); } } - void Draw(T *buffer, double x_um, double y_um, double z_um, + void Draw(float *signal, double x_um, double y_um, double z_um, std::size_t width, std::size_t height, double um_per_px, - double na, double intensity) { + double na, double intensity) const { const auto &filaments = filaments_; - RenderSpecimenImage(buffer, x_um, y_um, z_um, width, height, um_per_px, - na, intensity, rng_, [&](BLContext &ctx) { + RenderSpecimenImage(signal, x_um, y_um, z_um, width, height, um_per_px, + na, intensity, [&](BLContext &ctx) { for (const Filament &f : filaments) { BLPath path; path.moveTo(f.x0, f.y0); @@ -177,7 +126,7 @@ template class FilamentsSpecimen { } }; -template class NucleiSpecimen { +class NucleiSpecimen { struct Punctum { double x, y, radius, brightness; }; @@ -186,11 +135,11 @@ template class NucleiSpecimen { std::vector puncta; }; - rnd::mt19937 rng_; std::vector nuclei_; public: explicit NucleiSpecimen() { + rnd::mt19937 rng; rnd::uniform_real_distribution<> xy0Distrib(-2000.0, 2000.0); rnd::uniform_real_distribution<> nucleusRadiusDistrib(15.0, 30.0); rnd::uniform_int_distribution<> punctumCountDistrib(1, 6); @@ -199,30 +148,30 @@ template class NucleiSpecimen { for (int i = 0; i < 20; ++i) { Nucleus nucleus; - nucleus.x = xy0Distrib(rng_); - nucleus.y = xy0Distrib(rng_); - nucleus.radius = nucleusRadiusDistrib(rng_); + nucleus.x = xy0Distrib(rng); + nucleus.y = xy0Distrib(rng); + nucleus.radius = nucleusRadiusDistrib(rng); rnd::normal_distribution<> offsetDistrib(0.0, nucleus.radius / 3.0); - const int nPuncta = punctumCountDistrib(rng_); + const int nPuncta = punctumCountDistrib(rng); for (int p = 0; p < nPuncta; ++p) { - nucleus.puncta.push_back({nucleus.x + offsetDistrib(rng_), - nucleus.y + offsetDistrib(rng_), - punctumRadiusDistrib(rng_), - punctumBrightnessDistrib(rng_)}); + nucleus.puncta.push_back({nucleus.x + offsetDistrib(rng), + nucleus.y + offsetDistrib(rng), + punctumRadiusDistrib(rng), + punctumBrightnessDistrib(rng)}); } nuclei_.push_back(std::move(nucleus)); } } - void Draw(T *buffer, double x_um, double y_um, double z_um, + void Draw(float *signal, double x_um, double y_um, double z_um, std::size_t width, std::size_t height, double um_per_px, - double na, double intensity) { + double na, double intensity) const { const auto &nuclei = nuclei_; RenderSpecimenImage( - buffer, x_um, y_um, z_um, width, height, um_per_px, na, intensity, - rng_, [&](BLContext &ctx) { + signal, x_um, y_um, z_um, width, height, um_per_px, na, intensity, + [&](BLContext &ctx) { for (const Nucleus &n : nuclei) { ctx.fillCircle(BLCircle(n.x, n.y, n.radius), BLRgba32(40, 40, 40)); diff --git a/bench_SimulatedSpecimen.cpp b/bench_SimulatedSpecimen.cpp index 1321537..f5e0f70 100644 --- a/bench_SimulatedSpecimen.cpp +++ b/bench_SimulatedSpecimen.cpp @@ -1,3 +1,4 @@ +#include "Detector.h" #include "Gaussian2DFilter.h" #include "Specimen.h" @@ -7,11 +8,11 @@ #include void bm_filaments_specimen_draw(benchmark::State &state) { - FilamentsSpecimen specimen; + FilamentsSpecimen specimen; const auto z_um = double(state.range(0)); const std::size_t width = 512, height = 512; - std::vector buffer(width * height); - auto *data = buffer.data(); + std::vector signal(width * height); + auto *data = signal.data(); for ([[maybe_unused]] auto _ : state) { specimen.Draw(data, 0.0, 0.0, z_um, width, height, 0.2, 1.4f, 1000.0); benchmark::DoNotOptimize(data); @@ -23,11 +24,11 @@ BENCHMARK(bm_filaments_specimen_draw) ->Unit(benchmark::kMillisecond); void bm_nuclei_specimen_draw(benchmark::State &state) { - NucleiSpecimen specimen; + NucleiSpecimen specimen; const auto z_um = double(state.range(0)); const std::size_t width = 512, height = 512; - std::vector buffer(width * height); - auto *data = buffer.data(); + std::vector signal(width * height); + auto *data = signal.data(); for ([[maybe_unused]] auto _ : state) { specimen.Draw(data, 0.0, 0.0, z_um, width, height, 0.2, 1.4f, 1000.0); benchmark::DoNotOptimize(data); @@ -38,6 +39,25 @@ BENCHMARK(bm_nuclei_specimen_draw) ->Arg(50) ->Unit(benchmark::kMillisecond); +void bm_readout(benchmark::State &state) { + const auto level = float(state.range(0)); + const std::size_t width = 512, height = 512; + std::vector signal(width * height, level); + const float *signalData = level > 0.0f ? signal.data() : nullptr; + std::vector out(width * height); + auto *outData = out.data(); + rnd::mt19937 rng; + for ([[maybe_unused]] auto _ : state) { + ReadOut(signalData, outData, width * height, 50.0f, 100.0f, rng); + benchmark::DoNotOptimize(outData); + } +} +BENCHMARK(bm_readout) + ->Arg(0) + ->Arg(5) + ->Arg(1000) + ->Unit(benchmark::kMillisecond); + template void bm_gaussian_2d_filter(benchmark::State &state) { const std::size_t width = 512, height = 512; std::vector image(width * height, 42.0f); diff --git a/test_SimulatedCamera.cpp b/test_SimulatedCamera.cpp index dd0e974..184386a 100644 --- a/test_SimulatedCamera.cpp +++ b/test_SimulatedCamera.cpp @@ -1,3 +1,4 @@ +#include "Detector.h" #include "Gaussian2DFilter.h" #include "Specimen.h" @@ -6,7 +7,11 @@ #include #include +#include +#include +#include #include +#include TEST_CASE("FastGaussian2D-q") { using Catch::Matchers::WithinAbs; @@ -280,6 +285,83 @@ TEST_CASE("FastPoisson-tiny-lambda") { CHECK(sample >= 0.0); } +namespace { + +double Mean(const std::vector &v) { + return std::accumulate(v.begin(), v.end(), 0.0) / double(v.size()); +} + +double Variance(const std::vector &v, double mean) { + return std::transform_reduce( + v.begin(), v.end(), 0.0, std::plus<>{}, + [&](double s) { return (s - mean) * (s - mean); }) / + double(v.size()); +} + +} // namespace + +TEST_CASE("ReadOut-dark") { + using Catch::Matchers::WithinAbs; + rnd::mt19937 rng(12345); + constexpr std::size_t nPixels = 100000; + std::vector out(nPixels); + ReadOut(nullptr, out.data(), nPixels, 50.0f, 100.0f, rng); + + // Expected values account for clamping at 0 (2 sigma below the offset). + const double mean = Mean(out); + CHECK_THAT(mean, WithinAbs(100.4, 0.5)); + CHECK_THAT(std::sqrt(Variance(out, mean)), WithinAbs(49.0, 0.5)); +} + +TEST_CASE("ReadOut-signal") { + using Catch::Matchers::WithinAbs; + rnd::mt19937 rng(12345); + constexpr std::size_t nPixels = 100000; + const std::vector signal(nPixels, 1000.0f); + std::vector out(nPixels); + ReadOut(signal.data(), out.data(), nPixels, 0.0f, 0.0f, rng); + + const double mean = Mean(out); + CHECK_THAT(mean, WithinAbs(1000.0, 1.0)); + CHECK_THAT(Variance(out, mean), WithinAbs(1000.0, 30.0)); +} + +TEST_CASE("ReadOut-clamp") { + rnd::mt19937 rng(12345); + constexpr std::size_t nPixels = 100000; + const std::vector signal(nPixels, 1e6f); + std::vector out(nPixels); + ReadOut(signal.data(), out.data(), nPixels, 0.0f, 0.0f, rng); + + CHECK(std::all_of(out.begin(), out.end(), + [](std::uint16_t v) { return v == 65535; })); +} + +TEST_CASE("Specimen-Draw-deterministic") { + const std::size_t width = 64, height = 48; + std::vector a(width * height, -1.0f); + std::vector b(width * height, 42.0f); + + SECTION("filaments") { + FilamentsSpecimen specimen; + specimen.Draw(a.data(), 0.0, 0.0, 5.0, width, height, 10.0, 1.4, + 100.0); + specimen.Draw(b.data(), 0.0, 0.0, 5.0, width, height, 10.0, 1.4, + 100.0); + } + + SECTION("nuclei") { + NucleiSpecimen specimen; + specimen.Draw(a.data(), 0.0, 0.0, 5.0, width, height, 10.0, 1.4, + 100.0); + specimen.Draw(b.data(), 0.0, 0.0, 5.0, width, height, 10.0, 1.4, + 100.0); + } + + CHECK(a == b); + CHECK(std::any_of(a.begin(), a.end(), [](float v) { return v > 0.0f; })); +} + #ifdef USE_HIGHWAY_SIMD TEST_CASE("FastGaussian2D-SIMD-correctness") { using Catch::Matchers::WithinAbs;