[BACK]Return to pre_mod_1.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp / mpn / generic

Annotation of OpenXM_contrib/gmp/mpn/generic/pre_mod_1.c, Revision 1.1.1.3

1.1       maekawa     1: /* mpn_preinv_mod_1 (dividend_ptr, dividend_size, divisor_limb,
                      2:                       divisor_limb_inverted) --
                      3:    Divide (DIVIDEND_PTR,,DIVIDEND_SIZE) by the normalized DIVISOR_LIMB.
                      4:    DIVISOR_LIMB_INVERTED should be 2^(2*BITS_PER_MP_LIMB) / DIVISOR_LIMB +
                      5:    - 2^BITS_PER_MP_LIMB.
                      6:    Return the single-limb remainder.
                      7:
1.1.1.3 ! ohara       8: Copyright 1991, 1993, 1994, 2000, 2001, 2002 Free Software Foundation, Inc.
1.1       maekawa     9:
                     10: This file is part of the GNU MP Library.
                     11:
                     12: The GNU MP Library is free software; you can redistribute it and/or modify
1.1.1.2   maekawa    13: it under the terms of the GNU Lesser General Public License as published by
                     14: the Free Software Foundation; either version 2.1 of the License, or (at your
1.1       maekawa    15: option) any later version.
                     16:
                     17: The GNU MP Library is distributed in the hope that it will be useful, but
                     18: WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1.1.1.2   maekawa    19: or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
1.1       maekawa    20: License for more details.
                     21:
1.1.1.2   maekawa    22: You should have received a copy of the GNU Lesser General Public License
1.1       maekawa    23: along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
                     24: the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
                     25: MA 02111-1307, USA. */
                     26:
                     27: #include "gmp.h"
                     28: #include "gmp-impl.h"
                     29: #include "longlong.h"
                     30:
1.1.1.3 ! ohara      31:
        !            32: /* This function used to be documented, but is now considered obsolete.  It
        !            33:    continues to exist for binary compatibility, even when not required
        !            34:    internally.  */
1.1       maekawa    35:
                     36: mp_limb_t
                     37: mpn_preinv_mod_1 (mp_srcptr dividend_ptr, mp_size_t dividend_size,
                     38:                  mp_limb_t divisor_limb, mp_limb_t divisor_limb_inverted)
                     39: {
                     40:   mp_size_t i;
                     41:   mp_limb_t n0, r;
1.1.1.3 ! ohara      42:   mp_limb_t dummy;
1.1       maekawa    43:
1.1.1.3 ! ohara      44:   ASSERT (dividend_size >= 1);
        !            45:   ASSERT (divisor_limb & GMP_LIMB_HIGHBIT);
1.1       maekawa    46:
1.1.1.3 ! ohara      47:   r = dividend_ptr[dividend_size-1];
1.1       maekawa    48:   if (r >= divisor_limb)
1.1.1.3 ! ohara      49:     r -= divisor_limb;
1.1       maekawa    50:
1.1.1.3 ! ohara      51:   for (i = dividend_size - 2; i >= 0; i--)
1.1       maekawa    52:     {
                     53:       n0 = dividend_ptr[i];
                     54:       udiv_qrnnd_preinv (dummy, r, r, n0, divisor_limb, divisor_limb_inverted);
                     55:     }
                     56:   return r;
                     57: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>