| 261 | */ |
| 262 | template<typename F> |
| 263 | std::vector<typename F::Elem> FindRoots(const std::vector<typename F::Elem>& poly, typename F::Elem basis, const F& field) { |
| 264 | std::vector<typename F::Elem> roots; |
| 265 | CHECK_RETURN(poly.size() != 0, {}); |
| 266 | CHECK_RETURN(basis != 0, {}); |
| 267 | if (poly.size() == 1) return roots; // No roots when the polynomial is a constant. |
| 268 | roots.reserve(poly.size() - 1); |
| 269 | std::vector<std::vector<typename F::Elem>> stack = {poly}; |
| 270 | |
| 271 | // Invoke the recursive factorization algorithm. |
| 272 | if (!RecFindRoots(stack, 0, roots, false, 0, basis, field)) { |
| 273 | // Not fully factorizable. |
| 274 | return {}; |
| 275 | } |
| 276 | CHECK_RETURN(poly.size() - 1 == roots.size(), {}); |
| 277 | return roots; |
| 278 | } |
| 279 | |
| 280 | template<typename F> |
| 281 | std::vector<typename F::Elem> BerlekampMassey(const std::vector<typename F::Elem>& syndromes, size_t max_degree, const F& field) { |
no test coverage detected