From 98181933861614e80be1f8be1c82b48caf9d831a Mon Sep 17 00:00:00 2001 From: Andreas Tsouchlos Date: Fri, 25 Nov 2022 11:36:57 +0100 Subject: [PATCH] Return nullopt on decoding failure --- sw/cpp/src/cpp_decoders.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sw/cpp/src/cpp_decoders.cpp b/sw/cpp/src/cpp_decoders.cpp index 4a50b2d..e7f102e 100644 --- a/sw/cpp/src/cpp_decoders.cpp +++ b/sw/cpp/src/cpp_decoders.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include @@ -67,7 +68,7 @@ public: mH_zero_indices(find_zero(H)) { } - const Eigen::RowVectorXi + const std::optional decode(const Eigen::Ref& y) { Eigen::RowVectorXd s = Eigen::RowVectorXd::Zero(mH.cols()); Eigen::RowVectorXi x_hat; @@ -85,8 +86,7 @@ public: } } - return x_hat; - // TODO: Return 'None' + return std::nullopt; } private: @@ -128,7 +128,7 @@ private: B_sums = B_sums * mH.cast(); Eigen::RowVectorXd result = 4 * (x.array().pow(2) - 1) * x.array() + - (2 * x.array().inverse()) * B_sums.array(); + (2 * x.array().inverse()) * B_sums.array(); return result; } @@ -151,6 +151,7 @@ PYBIND11_MODULE(cpp_decoders, proximal) { pybind11::class_(proximal, "ProximalDecoder") .def(pybind11::init(), - "H"_a.noconvert(), "K"_a, "omega"_a, "gamma"_a, "eta"_a) + "H"_a.noconvert(), "K"_a = 100, "omega"_a = 0.0002, + "gamma"_a = .05, "eta"_a = 1.5) .def("decode", &ProximalDecoder::decode, "x"_a.noconvert()); } \ No newline at end of file