| 100 | /** Compute the trace map of (param*x) modulo mod, putting the result in out. */ |
| 101 | template<typename F> |
| 102 | void TraceMod(const std::vector<typename F::Elem>& mod, std::vector<typename F::Elem>& out, const typename F::Elem& param, const F& field) { |
| 103 | out.reserve(mod.size() * 2); |
| 104 | out.resize(2); |
| 105 | out[0] = 0; |
| 106 | out[1] = param; |
| 107 | |
| 108 | for (int i = 0; i < field.Bits() - 1; ++i) { |
| 109 | Sqr(out, field); |
| 110 | if (out.size() < 2) out.resize(2); |
| 111 | out[1] = param; |
| 112 | PolyMod(mod, out, field); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | /** One step of the root finding algorithm; finds roots of stack[pos] and adds them to roots. Stack elements >= pos are destroyed. |
| 117 | * |