8.5. Obtaining Commons Math

Problem

You need to use Jakarta Commons Math to work with complex numbers, matrices, statistics, or linear equations.

Solution

Download Jakarta Commons Math and put the necessary JAR files in your classpath. Because Commons Math has not yet been released, you will need to download the latest nightly snapshot of Commons Math from http://cvs.apache.org/builds/jakarta-commons/nightly/commons-math/. Once you have downloaded the latest nightly build, uncompress the distribution, and place the commons-math-1.0-RC1.jar file in your classpath.

Discussion

Jakarta Commons Math was created to provide some more advanced mathematical capabilities under an Apache-style license. Commons Math provides classes to work with complex numbers, utilities to calculate statistics, a matrix implementation, special functions, continued fractions, root-finding, interpolation, and bivariate regression. Commons Math depends on Commons Collections 3.0, Commons Lang 2.0, and Commons Logging 1.0.3. To obtain these dependencies, see Recipe 1.1, Recipe 5.1, and Recipe 7.9.

Warning

By the time this book is published, Commons Math 1.0 may be released. Make sure you look at the Commons Math project page (http://jakarta.apache.org/commons/math) and check for a release before downloading.

While the previous four recipes demonstrated classes and utilities available in Jakarta Commons Lang, the next five recipes demonstrate classes and utilities from Jakarta Commons Math. Simpler math utilities, which have wide application, will frequently be included in Commons Lang, and more complex utilities will be added to Commons Math. As both components continue to evolve, you may notice some overlap between the feature-set of Commons Lang and Commons Math.

See Also

Commons Math is a relatively new math library primarily motivated by licensing and community issues; all established math libraries were covered under a GPL or LGPL license. The Jakarta Commons community saw an opportunity to create a library, and through the hard work of a few dedicated developers in Commons, a very useful math library will soon be released. That being said, if you need a more mature math library, and your project can use LGPL components, look at the Colt Distribution from CERN (http://hoschek.home.cern.ch/hoschek/colt/).

For the authoritative cookbook of mathematics, pick up a copy of Numerical Recipes in C++ or Numerical Recipes in C (Cambridge University Press). These classic tomes contain a huge library of code and examples, but be forewarned, the mathematics will quickly intimidate the faint of math. More information about this indispensable text can be found at the Numerical Recipes website (http://www.nr.com/). Unlike all the components described throughout this book, the code and examples from both of these books is covered under a very restrictive license described at http://www.numerical-recipes.com/infotop.html#distinfo.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.152.58