MCPcopy Create free account
hub / github.com/ShahjalalShohag/code-library / inverse

Method inverse

Math/Subset Sum Problem.cpp:210–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208 return ans;
209 }
210 poly inverse(int n) const { // 1 / p(x) % x^n, O(nlogn)
211 assert(!is_zero()); assert(a[0] != 0);
212 poly ans{mint(1) / a[0]};
213 for(int i = 1; i < n; i *= 2) {
214 ans = (ans * mint(2) - ans * ans * mod_xk(2 * i)).mod_xk(2 * i);
215 }
216 return ans.mod_xk(n);
217 }
218 poly log(int n) const { //ln p(x) mod x^n
219 assert(a[0] == 1);
220 return (differentiate().mod_xk(n) * inverse(n)).integrate().mod_xk(n);

Callers

nothing calls this directly

Calls 2

is_zeroFunction · 0.85
mod_xkMethod · 0.45

Tested by

no test coverage detected