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

Method divmod

Math/Polynomial.cpp:261–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259 return {ans, A};
260 }
261 pair<poly, poly> divmod(const poly &b) const { // returns quotient and remainder of a mod b
262 if(size() < b.size()) return {poly{0}, *this};
263 int d = size() - b.size();
264 if(min(d, b.size()) < 250) return divmod_slow(b);
265 poly D = (reverse_it(d + 1) * b.reverse_it(d + 1).inverse(d + 1)).mod_xk(d + 1).reverse_it(d + 1, 1);
266 return {D, *this - (D * b)};
267 }
268 poly operator / (const poly &t) const {return divmod(t).first;}
269 poly operator % (const poly &t) const {return divmod(t).second;}
270 poly& operator /= (const poly &t) {return *this = divmod(t).first;}

Callers

nothing calls this directly

Calls 5

sizeFunction · 0.85
sizeMethod · 0.45
reverse_itMethod · 0.45
mod_xkMethod · 0.45
inverseMethod · 0.45

Tested by

no test coverage detected