| 38 | namespace Impl { |
| 39 | |
| 40 | DenseMtx Precode_Matrix::intermediate (DenseMtx &D) |
| 41 | { |
| 42 | // rfc 6330, pg 32 |
| 43 | // "c" and "d" are used to track row and columns exchange. |
| 44 | // since Eigen should track row exchange without actually swapping |
| 45 | // the data, we can call DenseMtx.row.swap without more overhead |
| 46 | // than actually having "d". so we're left only with "c", |
| 47 | // which is needed 'cause D does not have _params.L columns. |
| 48 | |
| 49 | std::vector<uint16_t> c; |
| 50 | |
| 51 | c.clear(); |
| 52 | c.reserve (_params.L); |
| 53 | DenseMtx C, X = A; |
| 54 | |
| 55 | bool success; |
| 56 | uint16_t i, u; |
| 57 | for (i = 0; i < _params.L; ++i) |
| 58 | c.emplace_back (i); |
| 59 | |
| 60 | std::tie (success, i, u) = decode_phase1 (X, D, c); |
| 61 | if (!success) |
| 62 | return C; |
| 63 | success = decode_phase2 (D, i, u); |
| 64 | if (!success) |
| 65 | return C; |
| 66 | // A now should be considered as being LxL from now |
| 67 | decode_phase3 (X, D, i); |
| 68 | X = DenseMtx (); // free some memory, X is not needed anymore. |
| 69 | decode_phase4 (D, i, u); |
| 70 | decode_phase5 (D, i); |
| 71 | // A now must be an LxL identity matrix: check it. |
| 72 | // CHECK DISABLED: phase4 does not modify A, as it's never readed |
| 73 | // again. So the Matrix is *not* an identity anymore. |
| 74 | //auto id_A = A.block (0, 0, _params.L, _params.L); |
| 75 | //for (uint16_t row = 0; row < id_A.rows(); ++row) { |
| 76 | // for (uint16_t col = 0; col < id_A.cols(); ++col) { |
| 77 | // if (static_cast<uint8_t> (id_A (row, col)) != (row == col ? 1 : 0)) |
| 78 | // return C; |
| 79 | // } |
| 80 | //} |
| 81 | A = DenseMtx(); // free A memory. |
| 82 | |
| 83 | C = DenseMtx (D.rows(), D.cols()); |
| 84 | for (i = 0; i < _params.L; ++i) |
| 85 | C.row (c[i]) = D.row (i); |
| 86 | |
| 87 | return C; |
| 88 | } |
| 89 | |
| 90 | // Used in decoding |
| 91 | DenseMtx Precode_Matrix::intermediate (DenseMtx &D, const Bitmask &mask, |