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

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

1.1.1.3 ! ohara       1: /* mpn_add_n -- Add equal length limb vectors.
1.1       maekawa     2:
1.1.1.3 ! ohara       3: Copyright 1992, 1993, 1994, 1996, 2000, 2002 Free Software Foundation, Inc.
1.1       maekawa     4:
                      5: This file is part of the GNU MP Library.
                      6:
                      7: The GNU MP Library is free software; you can redistribute it and/or modify
1.1.1.2   maekawa     8: it under the terms of the GNU Lesser General Public License as published by
                      9: the Free Software Foundation; either version 2.1 of the License, or (at your
1.1       maekawa    10: option) any later version.
                     11:
                     12: The GNU MP Library is distributed in the hope that it will be useful, but
                     13: WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1.1.1.2   maekawa    14: or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
1.1       maekawa    15: License for more details.
                     16:
1.1.1.2   maekawa    17: You should have received a copy of the GNU Lesser General Public License
1.1       maekawa    18: along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
                     19: the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
                     20: MA 02111-1307, USA. */
                     21:
                     22: #include "gmp.h"
                     23: #include "gmp-impl.h"
                     24:
1.1.1.3 ! ohara      25:
        !            26: #if GMP_NAIL_BITS == 0
        !            27:
1.1       maekawa    28: mp_limb_t
1.1.1.3 ! ohara      29: mpn_add_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n)
        !            30: {
        !            31:   mp_limb_t ul, vl, sl, rl, cy, cy1, cy2;
        !            32:
        !            33:   ASSERT (n >= 1);
        !            34:   ASSERT (MPN_SAME_OR_SEPARATE_P (rp, up, n));
        !            35:   ASSERT (MPN_SAME_OR_SEPARATE_P (rp, vp, n));
        !            36:
        !            37:   cy = 0;
        !            38:   do
        !            39:     {
        !            40:       ul = *up++;
        !            41:       vl = *vp++;
        !            42:       sl = ul + vl;
        !            43:       cy1 = sl < ul;
        !            44:       rl = sl + cy;
        !            45:       cy2 = rl < sl;
        !            46:       cy = cy1 | cy2;
        !            47:       *rp++ = rl;
        !            48:     }
        !            49:   while (--n != 0);
        !            50:
        !            51:   return cy;
        !            52: }
        !            53:
1.1       maekawa    54: #endif
1.1.1.3 ! ohara      55:
        !            56: #if GMP_NAIL_BITS >= 1
        !            57:
        !            58: mp_limb_t
        !            59: mpn_add_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n)
1.1       maekawa    60: {
1.1.1.3 ! ohara      61:   mp_limb_t ul, vl, rl, cy;
1.1       maekawa    62:
1.1.1.3 ! ohara      63:   ASSERT (n >= 1);
        !            64:   ASSERT (MPN_SAME_OR_SEPARATE_P (rp, up, n));
        !            65:   ASSERT (MPN_SAME_OR_SEPARATE_P (rp, vp, n));
1.1       maekawa    66:
                     67:   cy = 0;
                     68:   do
                     69:     {
1.1.1.3 ! ohara      70:       ul = *up++;
        !            71:       vl = *vp++;
        !            72:       rl = ul + vl + cy;
        !            73:       cy = rl >> GMP_NUMB_BITS;
        !            74:       *rp++ = rl & GMP_NUMB_MASK;
1.1       maekawa    75:     }
1.1.1.3 ! ohara      76:   while (--n != 0);
1.1       maekawa    77:
                     78:   return cy;
                     79: }
1.1.1.3 ! ohara      80:
        !            81: #endif

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