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

mercurial at gmplib.org mercurial at gmplib.org
Sun Jan 19 11:16:12 UTC 2014


details:   /var/hg/gmp/rev/9c312629dfe5
changeset: 16204:9c312629dfe5
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Jan 19 12:14:42 2014 +0100
description:
mini-gmp: Add mpz_{add,sub}mul{,_ui} functions.

details:   /var/hg/gmp/rev/9c629b71dc7d
changeset: 16205:9c629b71dc7d
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Jan 19 12:16:04 2014 +0100
description:
ChangeLog

diffstat:

 ChangeLog           |   3 ++-
 mini-gmp/mini-gmp.c |  40 ++++++++++++++++++++++++++++++++++++++++
 mini-gmp/mini-gmp.h |   4 ++++
 3 files changed, 46 insertions(+), 1 deletions(-)

diffs (77 lines):

diff -r 5e38be7dad47 -r 9c629b71dc7d ChangeLog
--- a/ChangeLog	Sun Jan 19 11:57:03 2014 +0100
+++ b/ChangeLog	Sun Jan 19 12:16:04 2014 +0100
@@ -2,7 +2,8 @@
 
 	* mini-gmp/mini-gmp.c (mpn_popcount): New function.
 	(mpz_popcount): Use it.
-	* mini-gmp/mini-gmp.h: Declare it.
+	(mpz_addmul_ui, mpz_addmul, mpz_submul_ui, mpz_submul): Added.
+	* mini-gmp/mini-gmp.h: Declare them.
 
 2014-01-18  Niels Möller  <nisse at lysator.liu.se>
 
diff -r 5e38be7dad47 -r 9c629b71dc7d mini-gmp/mini-gmp.c
--- a/mini-gmp/mini-gmp.c	Sun Jan 19 11:57:03 2014 +0100
+++ b/mini-gmp/mini-gmp.c	Sun Jan 19 12:16:04 2014 +0100
@@ -2021,6 +2021,46 @@
   r->_mp_size = (u->_mp_size < 0) ? - rn : rn;
 }
 
+void
+mpz_addmul_ui (mpz_t r, const mpz_t u, unsigned long int v)
+{
+  mpz_t t;
+  mpz_init (t);
+  mpz_mul_ui (t, u, v);
+  mpz_add (r, r, t);
+  mpz_clear (t);
+}
+
+void
+mpz_submul_ui (mpz_t r, const mpz_t u, unsigned long int v)
+{
+  mpz_t t;
+  mpz_init (t);
+  mpz_mul_ui (t, u, v);
+  mpz_sub (r, r, t);
+  mpz_clear (t);
+}
+
+void
+mpz_addmul (mpz_t r, const mpz_t u, const mpz_t v)
+{
+  mpz_t t;
+  mpz_init (t);
+  mpz_mul (t, u, v);
+  mpz_add (r, r, t);
+  mpz_clear (t);
+}
+
+void
+mpz_submul (mpz_t r, const mpz_t u, const mpz_t v)
+{
+  mpz_t t;
+  mpz_init (t);
+  mpz_mul (t, u, v);
+  mpz_sub (r, r, t);
+  mpz_clear (t);
+}
+
 

 /* MPZ division */
 enum mpz_div_round_mode { GMP_DIV_FLOOR, GMP_DIV_CEIL, GMP_DIV_TRUNC };
diff -r 5e38be7dad47 -r 9c629b71dc7d mini-gmp/mini-gmp.h
--- a/mini-gmp/mini-gmp.h	Sun Jan 19 11:57:03 2014 +0100
+++ b/mini-gmp/mini-gmp.h	Sun Jan 19 12:16:04 2014 +0100
@@ -131,6 +131,10 @@
 void mpz_mul_ui (mpz_t, const mpz_t, unsigned long int);
 void mpz_mul (mpz_t, const mpz_t, const mpz_t);
 void mpz_mul_2exp (mpz_t, const mpz_t, mp_bitcnt_t);
+void mpz_addmul_ui (mpz_t, const mpz_t, unsigned long int);
+void mpz_addmul (mpz_t, const mpz_t, const mpz_t);
+void mpz_submul_ui (mpz_t, const mpz_t, unsigned long int);
+void mpz_submul (mpz_t, const mpz_t, const mpz_t);
 
 void mpz_cdiv_qr (mpz_t, mpz_t, const mpz_t, const mpz_t);
 void mpz_fdiv_qr (mpz_t, mpz_t, const mpz_t, const mpz_t);


More information about the gmp-commit mailing list