Added check for vector dimensions to cpp proximal decoder
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
#include <Eigen/Dense>
|
||||
#include <bit>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <pybind11/eigen.h>
|
||||
#include <pybind11/numpy.h>
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include <pybind11/eigen.h>
|
||||
|
||||
#include <bit>
|
||||
|
||||
|
||||
namespace py11 = pybind11;
|
||||
using namespace pybind11::literals;
|
||||
@@ -33,6 +32,9 @@ public:
|
||||
|
||||
std::pair<std::optional<Eigen::RowVectorXi>, int>
|
||||
decode(const Eigen::Ref<const Eigen::VectorXd>& y) {
|
||||
if (y.size() != mH.cols())
|
||||
throw std::runtime_error("Length of vector must match H matrix");
|
||||
|
||||
Eigen::RowVectorXd s = Eigen::RowVectorXd::Zero(mH.cols());
|
||||
Eigen::RowVectorXi x_hat;
|
||||
Eigen::RowVectorXd r;
|
||||
@@ -129,4 +131,6 @@ PYBIND11_MODULE(cpp_decoders, proximal) {
|
||||
t[2].cast<double>(), t[3].cast<double>(),
|
||||
t[4].cast<double>()};
|
||||
}));
|
||||
|
||||
pybind11::register_exception<std::runtime_error>(proximal, "CppException");
|
||||
}
|
||||
Reference in New Issue
Block a user