tags:

views:

215

answers:

5

What are good resource to read up on for implementing numerical algorithms in pure java?

I know nothing about the interactions of the JVM & GC, and would love to learn more.

A: 

Java Number Cruncher is a good start. I don't think it deals with GC issues, though. Anyway, floating point precision issues are quite likely more relevant in numerical algorithms, usually. The book does demonstrate that doubles can actually be inferior to floats in some cases.

Joonas Pulakka
A: 

Apache Commons Math has some nice linear algebra libraries, among other things.

Linear algebra is the basis for lots of serious numerical work (e.g., finite difference, finite element, and boundary element formulations for problems in solid and fluid mechanics and heat transfer). AFAIK, most of that work is still done by commercial and in-house packages written in FORTRAN. Java and even C++ and C were not considered performant enough for such things back when I did them for a living. I'd be surprised if that has changed.

duffymo
Prepare to be (mildly) surprised. There's a lot of modern scientific/engineering software written, yes even the number crunching bits, in Java. I work in the oil business and there's a lot of seismic stuff done in Java. Sure Fortran and C++ still have an edge in speed, but it's smaller than it used to be and the hardware is a lot faster.
High Performance Mark
True, it's not always just the performance that matters. How crucial the speed is depends on the field of application, and Java's numerical performance is good enough for many real-world applications. And Apache Commons Math is great :-)
Joonas Pulakka
Please point out when performance doesn't matter. I've found that faster computers and more memory just means that the problems become larger and more complex. For scientific computing performance is a huge concern. That's the driving force behind the supercomputer and massive parallelization arms race.
duffymo
I will concede that I stopped doing that work for a living back in 1995, which is an eternity in this field. I'm actually happy at the evidence from Mark and Joonas, because I'd like to see Java brought to bear on those problems. I'll have to amend my views. Thanks for the education.
duffymo
I should come clean -- I don't (and wouldn't) use Java myself for high-performance number crunching. I'm working on a Fortran+MPI program tackling inverse geophysical problems, running on a cluster with 12,000 processor cores. They (the suits that is) don't let me use all those cores simultaneously, I've only managed to get 400 for about an hour one day, but I'm working towards highly scalable performance. But a lot of the scientific/engineering/financial stuff which needed Fortran on workstations back in the 90s is now do-able by Java on a PC.
High Performance Mark
Fortran/MPI was the way that massive scale CFD problems were being done by my engineering employer when I left in 1995. I'd bet that is still the technology stack. Your point is still a good one, Mark, but this remark is making my original comments look better.
duffymo
Performance obviously doesn't matter to many of the millions of people using Mathematica, for example. My company migrated from Fortran/C++ to OCaml/F# years ago and never looked back. A *lot* of scientific computing is now done with modern languages.
Jon Harrop
What kind of stuff does your company do, Jon?
duffymo
"Performance obviously doesn't matter to many of the millions of people using Mathematica, for example" - you've polled a significant number of them to determine this? I would agree if all you're doing is some simple symbolic manipulations, but can you be sure that this statement holds true if you're linking the Mathematica JAR into a Java app that uses the API for some longer-running calculations? I can see where performance sure would matter then. All use cases are not created equal.
duffymo
A: 

Hi

Pick up a copy of Numerical Recipes in C++. NR doesn't always contain the best algorithms for the problems it tackles, it's a pedagogical text not a library of optimised code. But the explanations are generally good and the range of topics is wide. By picking up the C++ version you can learn some Java while you translate the code. Also pick up a good book on the basics of floating-point arithmetic and numerical analysis.

Regards

Mark

High Performance Mark
Ordered Numericla Recipes already.What do you recommend for floating-point arithmetic and numerical analysis?
anon
I like Numerical Analysis by Burden and Faires but there's a myriad others. Have fun with NR.
High Performance Mark
+2  A: 

I enjoyed Object Oriented Implementation of Numerical Methods by Didier Besset. To be honest I use C++ almost exclusively but found this book interesting and fun nonetheless. It doesn't always use the best algorithm for the job, however.

I would also point you towards Matrix Computations by Golub & Van Loan. Not about Java by any means, but a mandatory text for anybody working in this area.

Drew Hall