M. Edward (Ed) Borasky wrote:
> benjohn / fysh.org wrote:
>> [Bill Kleb wrote]
>>> Here is an example used for computing correlations.
>>> It's almost a direct translation of several hundred
>>> lines of Fortran 77.
>>>
>>> If you can bare to look, please help, even it is simply
>>> to say "yo bonehead, why didn't you just require 'some_library'?"

Bil, Can I ask why you didn't you just call your fortran library
from Ruby by wrapping it as an extension?


I have no problem wrapping this little Fortran example:
==============================================================
c Demo of Ruby/Fortran

	function hello_ruby_func(i) result(j)
	   integer, intent(in) :: i ! input
	   integer             :: j ! output
	   j = i + 123
	end function hello_ruby_func
=============================================================
with this little Ruby/C extension which calls my
Fortran function
=============================================================
#include "ruby.h"

VALUE Ruby2C2Fortran = Qnil;
void Init_mytest();

VALUE method_test_f(VALUE self) {
	int x = 10;
	int y = hello_ruby_func_(&x);
	return INT2NUM(y);
}

void Init_ruby2c2fortran() {
	Ruby2C2Fortran = rb_define_module("Ruby2C2Fortran");
	rb_define_method(Ruby2C2Fortran, "test_f", method_test_f, 0);
}
===========================================================
and calling it as follows:
===========================================================
require 'ruby2c2fortran'
include Ruby2C2Fortran
puts test_f
===========================================================

> Well ... ok ... but why even write using something as low-level as a
> linear algebra library. I think this is a one-liner in R.


OTOH, there are still some good fortran libraries where it's
hard to find equivalents even in R.