[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gcd inum/big simplification
From: |
Kevin Ryde |
Subject: |
gcd inum/big simplification |
Date: |
Thu, 15 Apr 2004 11:41:45 +1000 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (gnu/linux) |
* numbers.c (scm_gcd): For inum/big, use mpz_gcd_ui by sharing code
with big/inum.
--- numbers.c.~1.234.~ 2004-04-15 11:22:44.000000000 +1000
+++ numbers.c 2004-04-15 11:39:39.000000000 +1000
@@ -1026,15 +1026,8 @@
}
else if (SCM_BIGP (y))
{
- SCM result = scm_i_mkbig ();
- SCM mx = scm_i_mkbig ();
- mpz_set_si (SCM_I_BIG_MPZ (mx), SCM_INUM (x));
- scm_remember_upto_here_1 (x);
- mpz_gcd (SCM_I_BIG_MPZ (result),
- SCM_I_BIG_MPZ (mx),
- SCM_I_BIG_MPZ (y));
- scm_remember_upto_here_2 (mx, y);
- return scm_i_normbig (result);
+ SCM_SWAP (x, y);
+ goto big_inum;
}
else
SCM_WTA_DISPATCH_2 (g_gcd, x, y, SCM_ARG2, s_gcd);
@@ -1044,7 +1037,9 @@
if (SCM_INUMP (y))
{
unsigned long result;
- long yy = SCM_INUM (y);
+ long yy;
+ big_inum:
+ yy = SCM_INUM (y);
if (yy == 0)
return scm_abs (x);
if (yy < 0)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gcd inum/big simplification,
Kevin Ryde <=