0

Is there anything similar to mpmath for scala?

More precisily, the only features of mpmath that I'm using are factorial (this is faster than factorial from python's math and works with big numbers) and binomial coefficient computations and setting the precision.

Thank you in advance.

Alper t. Turker
  • 34,230
  • 9
  • 83
  • 115
elfinorr
  • 189
  • 3
  • 12
  • I'm not sure, but it feels as if Apache Commons should have something in this combinatoric-computational direction. Maybe [CombinatoricsUtils](http://commons.apache.org/proper/commons-math/javadocs/api-3.3/org/apache/commons/math3/util/CombinatoricsUtils.html) or something like that? – Andrey Tyukin Apr 06 '18 at 13:36
  • @AndreyTyukin, thank you for your answer! Unfortunally, it throws exception for big numbers, for example mpmath can calculate (5*10^6)! quite fast, and this package can't at all. – elfinorr Apr 06 '18 at 14:37
  • Looks like it's a pretty specialized math library that can cope with big numbers that appear in combinatorics. Do you have any good reason to not use just that library, and then call an external python script from Scala? I'm not aware of any Scala libraries that attempted to get any market share in combinatorics, but it doesn't say much... – Andrey Tyukin Apr 06 '18 at 14:52
  • @AndreyTyukin wow, I didn't know that I could call python script from Scala, will check how it works, thank you. Actually I've been trying to rewrite my program using pyspark and mpmath there, but met other problems. – elfinorr Apr 06 '18 at 15:01
  • Scala can talk to the operating system, just like about any other general-purpose language, so you can ask the OS to run an arbitrary external program. Google 'scala.sys.process'. The result then becomes somewhat less OS-independent, because it's no longer pure JVM .class files, but some composition of scala code and external python scripts. There is also Jython that can run Python directly in JVM, but I'm not sure how easy/difficult it would be to use the library that you mentioned from that... – Andrey Tyukin Apr 06 '18 at 15:10
  • You have to decide whether it's easier to install the python interpreter and the required libraries on the target system, or whether it's easier to port the specialized library to Scala... – Andrey Tyukin Apr 06 '18 at 15:11

0 Answers0