0

I'm using Java Open Maple Library in a project and I'm wondering about how can I pass a big integer to the Maple Engine? I use the Java class BigInteger to represent my very large numbers. However Maple do not provide a support for this class. The only supported types are int, double and long. Has anyone found a workaround for this?

Thank you.

1 Answer 1

0

It's not an ideal solution, but starting with the com.maplesoft.openmaple.Numeric object referencing your arbitrary-precision integer, you could:

  1. Save the integer to a variable, say n, within the associated Maple session.
  2. Split up n into 64-bit chunks by iteratively dividing by 2^64. In Maple you can compute the remainder after dividing by 2^64 while simultaneously updating the value of 'n' with

    r := iquo(n, 2^64, 'n');
    

    After computing the remainder with the eval method on com.maplesoft.openmaple.Algebraic you can invoke the longValue() method to express it as a long.

  3. From all these 64-bit chunks build up a BigInteger.

1
  • I see that the same question has been posted on MaplePrimes at almost the same time. I would suggest going with the answer provided there (taking the Maple integer as a string and passing to the BigInteger constructor) unless you have a strong aesthetic aversion to using strings as an intermediate representation.
    – saforrest
    May 17, 2016 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.