Return nullopt on decoding failure
This commit is contained in:
parent
c9a4b1b61e
commit
9818193386
@ -2,6 +2,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <pybind11/numpy.h>
|
#include <pybind11/numpy.h>
|
||||||
#include <pybind11/pybind11.h>
|
#include <pybind11/pybind11.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
|
||||||
#include <pybind11/eigen.h>
|
#include <pybind11/eigen.h>
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ public:
|
|||||||
mH_zero_indices(find_zero(H)) {
|
mH_zero_indices(find_zero(H)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const Eigen::RowVectorXi
|
const std::optional<Eigen::RowVectorXi>
|
||||||
decode(const Eigen::Ref<const Eigen::VectorXd>& y) {
|
decode(const Eigen::Ref<const Eigen::VectorXd>& y) {
|
||||||
Eigen::RowVectorXd s = Eigen::RowVectorXd::Zero(mH.cols());
|
Eigen::RowVectorXd s = Eigen::RowVectorXd::Zero(mH.cols());
|
||||||
Eigen::RowVectorXi x_hat;
|
Eigen::RowVectorXi x_hat;
|
||||||
@ -85,8 +86,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return x_hat;
|
return std::nullopt;
|
||||||
// TODO: Return 'None'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -151,6 +151,7 @@ PYBIND11_MODULE(cpp_decoders, proximal) {
|
|||||||
|
|
||||||
pybind11::class_<ProximalDecoder>(proximal, "ProximalDecoder")
|
pybind11::class_<ProximalDecoder>(proximal, "ProximalDecoder")
|
||||||
.def(pybind11::init<MatrixXiR, int, double, double, double>(),
|
.def(pybind11::init<MatrixXiR, int, double, double, double>(),
|
||||||
"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());
|
.def("decode", &ProximalDecoder::decode, "x"_a.noconvert());
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user