MCPcopy Create free account
hub / github.com/ElementsProject/elements / FindRoots

Function FindRoots

src/minisketch/src/sketch_impl.h:263–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261 */
262template<typename F>
263std::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
280template<typename F>
281std::vector<typename F::Elem> BerlekampMassey(const std::vector<typename F::Elem>& syndromes, size_t max_degree, const F& field) {

Callers 2

FullDecodeFunction · 0.85
DecodeMethod · 0.85

Calls 3

RecFindRootsFunction · 0.85
sizeMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected