[Gmp-commit] /var/hg/gmp: 3 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Sun Jan 19 10:57:10 UTC 2014


details:   /var/hg/gmp/rev/ad717be19f1c
changeset: 16201:ad717be19f1c
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Jan 19 11:54:02 2014 +0100
description:
mini-gmp: add mpn_popcount.

details:   /var/hg/gmp/rev/98965b2d3a30
changeset: 16202:98965b2d3a30
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Jan 19 11:56:06 2014 +0100
description:
ChangeLog

details:   /var/hg/gmp/rev/5e38be7dad47
changeset: 16203:5e38be7dad47
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Jan 19 11:57:03 2014 +0100
description:
Copyright year.

diffstat:

 ChangeLog           |   6 ++++++
 mini-gmp/mini-gmp.c |  22 +++++++++++++++-------
 mini-gmp/mini-gmp.h |   4 +++-
 3 files changed, 24 insertions(+), 8 deletions(-)

diffs (80 lines):

diff -r 7079887fac7b -r 5e38be7dad47 ChangeLog
--- a/ChangeLog	Sat Jan 18 19:08:43 2014 +0100
+++ b/ChangeLog	Sun Jan 19 11:57:03 2014 +0100
@@ -1,3 +1,9 @@
+2014-01-19 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* mini-gmp/mini-gmp.c (mpn_popcount): New function.
+	(mpz_popcount): Use it.
+	* mini-gmp/mini-gmp.h: Declare it.
+
 2014-01-18  Niels Möller  <nisse at lysator.liu.se>
 
 	* tests/mpn/t-aors_1.c: Test also mpn_sec_add_1 and mpn_sec_sub_1.
diff -r 7079887fac7b -r 5e38be7dad47 mini-gmp/mini-gmp.c
--- a/mini-gmp/mini-gmp.c	Sat Jan 18 19:08:43 2014 +0100
+++ b/mini-gmp/mini-gmp.c	Sun Jan 19 11:57:03 2014 +0100
@@ -2,7 +2,7 @@
 
    Contributed to the GNU project by Niels Möller
 
-Copyright 1991-1997, 1999-2013 Free Software Foundation, Inc.
+Copyright 1991-1997, 1999-2014 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -3587,20 +3587,28 @@
 }
 
 mp_bitcnt_t
+mpn_popcount (mp_srcptr p, mp_size_t n)
+{
+  mp_size_t i;
+  mp_bitcnt_t c;
+
+  for (c = 0, i = 0; i < n; i++)
+    c += gmp_popcount_limb (p[i]);
+
+  return c;
+}
+
+mp_bitcnt_t
 mpz_popcount (const mpz_t u)
 {
-  mp_size_t un, i;
-  mp_bitcnt_t c;
+  mp_size_t un;
 
   un = u->_mp_size;
 
   if (un < 0)
     return ~(mp_bitcnt_t) 0;
 
-  for (c = 0, i = 0; i < un; i++)
-    c += gmp_popcount_limb (u->_mp_d[i]);
-
-  return c;
+  return mpn_popcount (u->_mp_d, un);
 }
 
 mp_bitcnt_t
diff -r 7079887fac7b -r 5e38be7dad47 mini-gmp/mini-gmp.h
--- a/mini-gmp/mini-gmp.h	Sat Jan 18 19:08:43 2014 +0100
+++ b/mini-gmp/mini-gmp.h	Sun Jan 19 11:57:03 2014 +0100
@@ -1,6 +1,6 @@
 /* mini-gmp, a minimalistic implementation of a GNU GMP subset.
 
-Copyright 2011-2013 Free Software Foundation, Inc.
+Copyright 2011-2014 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -93,6 +93,8 @@
 mp_bitcnt_t mpn_scan0 (mp_srcptr, mp_bitcnt_t);
 mp_bitcnt_t mpn_scan1 (mp_srcptr, mp_bitcnt_t);
 
+mp_bitcnt_t mpn_popcount (mp_srcptr, mp_size_t);
+
 mp_limb_t mpn_invert_3by2 (mp_limb_t, mp_limb_t);
 #define mpn_invert_limb(x) mpn_invert_3by2 ((x), 0)
 


More information about the gmp-commit mailing list