Changed cpp ProximalDecoder implementation to always return x_hat
This commit is contained in:
@@ -67,10 +67,12 @@ public:
|
||||
* This function assumes a BPSK modulated signal and an AWGN channel.
|
||||
* @param y Vector of received values. (y = x + w, where 'x' is element of
|
||||
* [-1, 1]^n and 'w' is noise)
|
||||
* @return Most probably sent codeword (element of [0, 1]^n). If decoding
|
||||
* fails, the returned value is 'None'
|
||||
* @return \b std::pair of the form (x_hat, num_iter), x_hat is the most
|
||||
* probably sent codeword and num_iter is the number of iterations that were
|
||||
* performed. If the parity check fails and no valid codeword is reached,
|
||||
* num_iter is -1
|
||||
*/
|
||||
std::pair<std::optional<RowVectori<t_n>>, int>
|
||||
std::pair<RowVectori<t_n>, int>
|
||||
decode(const Eigen::Ref<const RowVectord<t_n>>& y) {
|
||||
if (y.size() != mH.cols())
|
||||
throw std::runtime_error("Length of vector must match H matrix");
|
||||
@@ -95,12 +97,19 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
return {std::nullopt, mK};
|
||||
return {x_hat, -1};
|
||||
}
|
||||
|
||||
/// Private members are not private in order to make the class easily
|
||||
/// picklable
|
||||
// private:
|
||||
/**
|
||||
* @brief Get the values of all member variables necessary to recreate an
|
||||
* exact copy of this class. Used for pickling
|
||||
* @return \b std::tuple
|
||||
*/
|
||||
auto get_decoder_state() const {
|
||||
return std::tuple(mK, mOmega, mGamma, mEta, mH);
|
||||
}
|
||||
|
||||
private:
|
||||
const int mK;
|
||||
const double mOmega;
|
||||
const double mGamma;
|
||||
|
||||
@@ -17,7 +17,13 @@ using namespace pybind11::literals;
|
||||
.def("decode", &ProximalDecoder<m, n>::decode, "x"_a.noconvert()) \
|
||||
.def(py::pickle( \
|
||||
[](const ProximalDecoder<m, n>& a) { \
|
||||
return py::make_tuple(a.mH, a.mK, a.mOmega, a.mGamma, a.mEta); \
|
||||
MatrixiR<m, n> H; \
|
||||
int K; \
|
||||
double omega; \
|
||||
double gamma; \
|
||||
double eta; \
|
||||
std::tie(H, K, omega, gamma, eta) = a.get_decoder_state(); \
|
||||
return py::make_tuple(H, K, omega, gamma, eta); \
|
||||
}, \
|
||||
[](py::tuple t) { \
|
||||
return ProximalDecoder<m, n>{ \
|
||||
|
||||
Reference in New Issue
Block a user