~mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
math/mp-sqrt.c, math/pgen-granfrob.c: Publish `squarep' function.
[catacomb]
/
math
/
pgen-granfrob.c
diff --git
a/math/pgen-granfrob.c
b/math/pgen-granfrob.c
index
98c8f8c
..
0516539
100644
(file)
--- a/
math/pgen-granfrob.c
+++ b/
math/pgen-granfrob.c
@@
-36,16
+36,6
@@
/*----- Main code ---------------------------------------------------------*/
/*----- Main code ---------------------------------------------------------*/
-static int squarep(mp *n)
-{
- mp *t = MP_NEW;
- int rc;
-
- if (MP_NEGP(n)) return (0);
- t = mp_sqrt(t, n); t = mp_sqr(t, t);
- rc = MP_EQ(t, n); mp_drop(t); return (rc);
-}
-
/* --- @pgen_granfrob@ --- *
*
* Arguments: @mp *n@ = an integer to test
/* --- @pgen_granfrob@ --- *
*
* Arguments: @mp *n@ = an integer to test
@@
-103,7
+93,7
@@
int pgen_granfrob(mp *n, int a, int b)
e = mp_jacobi(&md, n);
/* If %$\Delta$% is a perfect square then the test can't work. */
e = mp_jacobi(&md, n);
/* If %$\Delta$% is a perfect square then the test can't work. */
- if (e == 1 && squarep(&md)) { rc = PGEN_ABORT; goto end; }
+ if (e == 1 &&
mp_
squarep(&md)) { rc = PGEN_ABORT; goto end; }
} else {
/* Determine parameters. Use Selfridge's `Method A': choose the first
* %$\Delta$% from the sequence %$5$%, %$-7$%, %%\dots%%, such that
} else {
/* Determine parameters. Use Selfridge's `Method A': choose the first
* %$\Delta$% from the sequence %$5$%, %$-7$%, %%\dots%%, such that
@@
-113,7
+103,7
@@
int pgen_granfrob(mp *n, int a, int b)
wa = 1; wd = 5;
for (;;) {
e = mp_jacobi(&md, n); if (e != +1) break;
wa = 1; wd = 5;
for (;;) {
e = mp_jacobi(&md, n); if (e != +1) break;
- if (wd == 25 && squarep(n)) { rc = PGEN_FAIL; goto end; }
+ if (wd == 25 &&
mp_
squarep(n)) { rc = PGEN_FAIL; goto end; }
wd += 2; md.f ^= MP_NEG;
}
a = 1; d = wd;
wd += 2; md.f ^= MP_NEG;
}
a = 1; d = wd;