Skip to content
/ gsl4r Public

GNU Scientific Library wrapped via FFI for Ruby, JRuby, etc...

License

Unknown, LGPL-3.0 licenses found

Licenses found

Unknown
LICENSE
LGPL-3.0
LICENSE.LGPLv3
Notifications You must be signed in to change notification settings

colbygk/gsl4r

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

== Description

ALPHA - ALPHA - ALPHA

GSL4r
Ruby GNU Scientific Library via FFI

The Foreign Function Interface allows for run-time bindings to shared libraries. Using FFI to interface between Ruby and other libraries written in other languages makes these libraries runnable across all Ruby interpreters that have FFI capabilties (MRI, JRuby, etc...).

This avoids the complications with implementation specific C extensions or Java Native Interfaces in the case of JRuby.

== Documentation

This project is currently in its alpha stages and as of 22 Mar 2010, I have only pushed a library for using Complex functions in GSL, all constants are defined, and handling pointers to blocks and vectors and basic vector functions.

== Getting Started

Right now you can look at the existing project by cloning the GIT repository via:

git clone git://rubyforge.org/gsl4r.git

== Installing gsl4r

gem install -r gsl4r

== Examples

Also see the examples directory in the gem.

irb -r rubygems -r gsl4r -r gsl4r/complex
irb(main):001:0> include GSL4r::Complex
=> Object
irb(main):004:0> a=GSL_Complex.create(1,1)
=> (1.0,1.0)
irb(main):005:0> b=GSL_Complex.create(2,2)
irb(main):009:0> a.abs
=> 1.4142135623731
irb(main):012:0> b.add(a)
=> (3.0,3.0)
irb(main):013:0> a.logabs
=> 0.346573590279973
irb(main):014:0> a.gsl_complex_logabs
=> 0.346573590279973
irb(main):016:0> include GSL4r::Complex::Methods
=> Object
irb(main):015:0> gsl_complex_add(a,b)
=> (3.0,3.0)
...
irb(main):010:0> require 'gsl4r/const'
=> true
irb(main):011:0> include GSL4r::PhysicalConstants
=> Object
irb(main):013:0> p CGS::JOULE
10000000.0
irb(main):014:0> p MKS::ERG
1.0e-07
...
irb -r rubygems -r gsl4r -r gsl4r/vector
irb(main):001:0> include GSL4r::Vector
=> Object
irb(main):002:0> a=GSL_Vector.create(3)
=> #<GSL4r::Vector::GSL_Vector:0x5ea038>
irb(main):003:0> b=GSL_Vector.create(3)
=> #<GSL4r::Vector::GSL_Vector:0x5e66f4>
irb(main):004:0> a.set_with_array([1,2,3])
=> #<FFI::Pointer address=0x2db2e0>
irb(main):005:0> b.set_with_array([4,5,6])
=> #<FFI::Pointer address=0x4f8260>
irb(main):006:0> a.mul(b)
=> 0
irb(main):012:0> a.values
=> [4.0, 10.0, 18.0]
...

== Questions and/or Comments

Feel free to email {Colby Gutierrez-Kraybill}[mailto:colby@astro.berkeley.edu] with any questions.

== Copyright

See LICENSE and LICENSE.LPGLv3

About

GNU Scientific Library wrapped via FFI for Ruby, JRuby, etc...

Resources

License

Unknown, LGPL-3.0 licenses found

Licenses found

Unknown
LICENSE
LGPL-3.0
LICENSE.LGPLv3

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages