2012 Grant Accomplishment Report
The following two projects have been completed, and their deliverables have been accepted by the grant committee.
- SciRuby and NMatrix
- Creosote - A Mathematic Package For Ruby
The summary of their final reports is as follows:
SciRuby and NMatrix
Ruby Science Foundation
NMatrix is a fast, modern linear algebra library for Ruby with support for dense as well as two types of sparse matrices. Written in C, NMatrix makes use of ATLAS for floating point matrix operations, but is also working toward rational and Ruby object matrix support.
NMatrix is a core component of the SciRuby Project, under the umbrella of the Ruby Science Foundation. We believe that adoption for Ruby in the sciences is currently limited by the lack of numerical, visualization, and scientific libraries – but that interest in these areas is high.
We utilized our Ruby Association grant to hire three student fellows to work on NMatrix.
Ruby/GSL (rb-gsl), the gem that allows Ruby to make use of the GNU Scientific Library, previously worked with NArray, but not NMatrix. Masaomi Hatakeyama, together with John Woods, wrote a fork which will eventually be submitted as a patch to enable rb-gsl to work with NMatrix. The fork is currently available at http://github.com/sciruby/rb-gsl/, and is the most critical step in allowing interoperability between NMatrix and the other SciRuby component projects (e.g., Statsample).
Masa also wrote a benchmark script for comparing some operations between GSL, NMatrix, and NArray (https://github.com/masaomi/benchmark) and dramatically improved RSpec coverage for NMatrix.
Documentation & Usability
Carlos Agarie worked to improve the documentation for NMatrix and SciRuby in general, ensuring that nearly all user-exposed functions are properly documented. He also submitted a patch to the RDoc project to improve parsing of C++ source code.
Generally, Carlos worked on improving usability of NMatrix, by introducing shortcut functions such as #row and #column. Carlos has also been working steadily on rational support for matrix inversion and determinant calculation.
It is worth noting that Carlos wrote SciRuby’s successful application to Google Summer of Code 2013, and he plans to serve as a mentor this summer.
Stability and Basic Features
Ryan’s fellowship term began after Carlos’ and Masa’s, so his work is ongoing. He has been working on implementing an #each_stored_with_indices iterator for sparse matrices, which allows a programmer to iterate only across the values stored in a matrix rather than every cell. In addition, Ryan is working on eigenvector and eigenvalue decomposition, as well as row reduction.
Creosote - A Mathematics Package for Ruby
The Creosote project under the Ruby Association 2012 Grant aims to:
- Support up-to-date GMP, MPFR, and Msieve libraries, and extensive
documentation for each,
- Create Ruby bindings for GMP-ECM
- Create Ruby bindings for MPC
- Create Creosote, a library that allows various mathematical libraries
to be bridged, in Ruby
https://github.com/srawlins/gmp (bindings for GMP and MPFR)
- At this point, the gmp gem exposes over 70 functions from GMP’s Integer
Functions interface, over 25 from the Rational Number Functions interface,
and over 33 from the Floating-point Functions interface.
- In addition, seven Ruby methods expose the Random Number Functions
- The gmp gem is currently documented with a 31-page manual and rdoc.
- At this point the gmp gem exposes over 55 functions from MPFR’s
- The GMP-ECM API consists entirely of one very large struct, *ecm_params
* (with 29 members), and one method (*ecm_factor(mpz_t, mpz_t, double,
ecm_params)*). *ecm_factor* was bridged to Ruby as *GMP::Z#ecm_factor*.
The difficult component of these bindings is supporting all of the types of
fields in *ecm_params*. In total, the parameter types include *mpz_t* (*
GMP::Z* in Ruby), *int* (*Fixnum* in Ruby), *double* (*Float* in Ruby), *
FILE** (*IO* in Ruby), *char** (*String* in Ruby), and *gmp_randstate_t*(
*GMP::RandState* in Ruby).
- During the grant period, support was written in the bindings for about
half of the fields in *ecm_params*, which can be found in the gmp_ecm
- more than 40 functions from the MPC Complex Numbers interface have
been bridged in the gnu_mpc gem.
- more than 90% of the methods exposed in the gnu_mpc gem are heavily
tested. The test suite includes over 160 test examples.
- Approximately 10 functions from the MPC interface have not been
- The gnu_mpc gem has largely been documented in *manual.md*, which gets
compiled into a 12-page *manual.pdf* and *manual.html*, using Pandoc (*
make* will compile the manual if Pandoc is installed).
- Creosote is a library with two goals. It allows Ruby users to install
C Extension gems and their prerequisites, similar to rvm installing libyaml
et al. in order to install a Ruby. Its end goal, however, is to allow
various mathematical C Extension libraries to share data.
- This libaray is largely ready for a public release. At present, the
library “knows about” GMP, MPFR, MPC, and Msieve. It can be queried for the
latest version of each package. It can also unpack, configure, make, check,
and install each of these packages. The packages install to *
- Installing the packages is made useful when we install certain gems
and specify specific arguments for *ruby extconf.rb*. This is made
possible with the *creosote gem install* command.