Greetings!
Andrei Zorine <zoav1@uic.nnov.ru> writes:
> hello,
> I have this to report:
>
> 1) primep(2^31-1) hangs. I don't see why. Given separately, lines from
> (defun pripmep...) (see rat3c.lisp) work fine. For other powers
> (... 29, 30, 32,...) it works fine.
> 2) (defun primep...) tries to factor its argument which is very slow.
> 3) faster algorithhm is easily introducible: just load primeq.lisp
> from Prof. Fateman's MockMathematica, and add (define jacobi-symbol(p
> q) (JacobiSymbol p q)) line. this can be put to share/, or even
> replace native maxima's primep() in rat3c.lisp.
> 4) MocksMMA's primeq(2^98765-1) causes frame stack overflow.
> 5) 2^98765-1 is processed in the twinkling of an eye with GMP's
> mpz_probab_prime_p() function (I tested with a separate C program).
>
> I worked with maxima 5.9.0 + gcl 2.5.2. It is possible that statements
> 1) and 4) aren't true with the current CVS maxima. Anyway, the fifth
> statement is connected with another discussion in this list. Recall
> the list processing routins in maxima question. Should maxima have
> wrappers for useful lisp functions? Here it's one more layer down: GCL
> uses GMP library which has some useful function; GCL doesn't provide
> this function; how can the function be accessed at the Maxima level?
>
Unfortunately, unless mpz_probab_primep is compiled in at C link time,
you will not be able to access it. It should be possible to relink at
the C level via GCL's (compiler::link...) function. If we restore the
faslink function, this should also be possible at runtime as opposed
to compile time.
Once linked in, you should be able to compile something like the
following in a lisp file:
(clines "
#define MP(x) (&((x)->big.big_mpz_t))
static
object my_mpz_probab_prime_p (obj)
object obj;
{
if (mpz_probab_prime_p(MP(obj)))
return Ct;
else
return Cnil;
}
(defentry my-prime-p (object) (object my_mpz_probab_prime_p))
Would be interested to know if this performs better for you. We could
export this and any other gmp function by default if desired.
Take care,
> --
> Andrei Zorine
>
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
>
>
--
Camm Maguire camm@enhanced.com
==========================================================================
"The earth is but one country, and mankind its citizens." -- Baha'u'llah