gsl

Posted by colby

fig 1 - Testing of Ruby FFI wrappers for GSL against results from direct C calls

Wrapping FFI based ruby calls to GSL requires handling 1000+ functions with their various features of calling arguments and returns. That's an error prone business and I wanted to have tests that would automatically check that my wrappers results match up with results from calling GSL functions within a C program.[1]

This made me depressed.

I was looking at having to hand code C programs to generate answers from functions like, "gsl_complex_sqrt_real(2.0)" (which is (1.4142135623731,0.0) by the by). And then another set of Ruby programs that would cross check those answers against my FFI wrappered calls to GSL. That's a lot of extra coding (see fig 1 for an individual test).

I chewed on this for several days, and when I had time to work on GSL4r again, I decided to add a GSL4r::Harness module, which would include the following methods:

  • write_c_tests
  • compile_c_tests
  • run_c_tests
Posted by colby

Added automatically generated method wrappers for calls into the GSL library using the object itself:

rgslffi GSL4r is a set of wrapper routines I'm creating around GNU Scientific Library (GSL) mathematical routines using the Foreign Function Interface (FFI) library for Ruby/JRuby. Using FFI helps avoid tying GSL only to the C based Ruby interpreters and potentially will make the library universally available across all Ruby implementations. Something we'd like to have while using JRuby for the ATA.