1 /* mpn_bdiv_q -- Hensel division with precomputed inverse, returning quotient.
3 Contributed to the GNU project by Torbjorn Granlund.
5 THE FUNCTIONS IN THIS FILE ARE INTERNAL WITH MUTABLE INTERFACES. IT IS ONLY
6 SAFE TO REACH THEM THROUGH DOCUMENTED INTERFACES. IN FACT, IT IS ALMOST
7 GUARANTEED THAT THEY WILL CHANGE OR DISAPPEAR IN A FUTURE GMP RELEASE.
9 Copyright 2006, 2007, 2009 Free Software Foundation, Inc.
11 This file is part of the GNU MP Library.
13 The GNU MP Library is free software; you can redistribute it and/or modify
14 it under the terms of the GNU Lesser General Public License as published by
15 the Free Software Foundation; either version 3 of the License, or (at your
16 option) any later version.
18 The GNU MP Library is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
21 License for more details.
23 You should have received a copy of the GNU Lesser General Public License
24 along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
30 /* Computes Q = N / D mod B^n. */
33 mpn_bdiv_q (mp_ptr qp,
34 mp_srcptr np, mp_size_t nn,
35 mp_srcptr dp, mp_size_t dn,
40 if (BELOW_THRESHOLD (dn, DC_BDIV_Q_THRESHOLD))
42 MPN_COPY (tp, np, nn);
43 binvert_limb (di, dp[0]); di = -di;
44 mpn_sbpi1_bdiv_q (qp, tp, nn, dp, dn, di);
46 else if (BELOW_THRESHOLD (dn, MU_BDIV_Q_THRESHOLD))
48 MPN_COPY (tp, np, nn);
49 binvert_limb (di, dp[0]); di = -di;
50 mpn_dcpi1_bdiv_q (qp, tp, nn, dp, dn, di);
54 mpn_mu_bdiv_q (qp, np, nn, dp, dn, tp);
60 mpn_bdiv_q_itch (mp_size_t nn, mp_size_t dn)
62 if (BELOW_THRESHOLD (dn, MU_BDIV_Q_THRESHOLD))
65 return mpn_mu_bdiv_q_itch (nn, dn);