Giter Site home page Giter Site logo

petrushka / rb-gsl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sciruby/rb-gsl

0.0 1.0 0.0 5.48 MB

Ruby interface to the GNU Scientific Library

Home Page: https://github.com/SciRuby/rb-gsl

License: Other

Ruby 15.27% Shell 0.01% C 81.36% C++ 3.36%

rb-gsl's Introduction

Ruby/GSL, a Ruby interface to GSL (GNU Scientific library)

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License.

Description

Ruby/GSL is a Ruby interface to the GNU Scientific Library (GSL), for numerical computing with Ruby.

Ruby/GSL is compatible with GSL versions upto 2.1.

Usage with GSL 2.1

As of this release, GSL 2.1 has not made it's way into the Debian stable repositories. Hence, after compiling GSL 2.1 from source, you will need to set the installation location in your LD_LIBRARY_PATH variable. After following standard GSL 2.1 installation procedures, you should do: export LD_LIBRARY_PATH=/usr/local/lib

The need to do this should not arise if GSL has been installed from apt-get.

Installation

Ruby/GSL may be installed as a Ruby Gem by simply running

gem install gsl

Note that the GSL libraries must already be installed before Ruby/GSL can be installed:

Debian/Ubuntu: +libgsl0-dev+ Fedora/SuSE: +gsl-devel+ Gentoo: +sci-libs/gsl+ OS X: brew install gsl

It is recommended to install the GNU plotutils package. Some of the example scripts in the +examples/+ directory use the +graph+ utility included in the package to plot the results. Windows cygwin binaries of GNU plotutils and related packages are available here.

NMatrix and NArray usage

Ruby/GSL works with NMatrix and NArray for a variety of methods. See the docs for a detailed list.

Basic Installation

In order to use rb-gsl with NMatrix you must first set the NMATRIX environment variable and then install rb-gsl: gem install nmatrix export NMATRIX=1 gem install rb-gsl

This will compile rb-gsl with NMatrix specific functions.

For using rb-gsl with NArray: gem install narray export NARRAY=1 gem install rb-gsl

Note that setting both NMATRIX and NARRAY variables will lead to undefined behaviour. Only one can be used at a time.

NMatrix basic usage

Convert an NMatrix 1D vector to GSL::Vector:

require 'gsl'

nm = NMatrix.new([5], [1,2,3,4,5], dtype: :float64)
#=> [1.0, 2.0, 3.0, 4.0, 5.0]
nm.to_gslv
# => GSL::Vector
# [ 1.000e+00 2.000e+00 3.000e+00 4.000e+00 5.000e+00 ]

Convert an integer 2D NMatrix to GSL::Matrix::Int:

require 'gsl'
nm = NMatrix.new([3,3], [2]*9, dtype: :int32)
#=> 
#[
#  [2, 2, 2]   [2, 2, 2]   [2, 2, 2] ]
nm.to_gslm
#=> GSL::Matrix::Int
#[ 2 2 2 
#  2 2 2 
#  2 2 2 ]

Convert GSL::Vector to 1D NMatrix:

g = GSL::Vector.alloc(1,2,3,4)
# => GSL::Vector
# [ 1.000e+00 2.000e+00 3.000e+00 4.000e+00 ]
g.to_nm
# => [1.0, 2.0, 3.0, 4.0]

to_nm can be used on all sorts of GSL::Vector and GSL::Matrix objects to convert them to NMatrix.

For a detailed list of methods that are compatible with NMatrix, see 'nmatrix' in the docs.

Reference

The Ruby/GSL reference manual follows and borrows large parts of the GSL reference manual.

Examples

See scripts in +examples/+ and +test/+ directories.

Related Projects

  • ruby-gsl: Another Ruby binding, developed by Arno Erpenbeck.

Licence

Ruby/GSL is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.

Bug Reports

Any bug reports are welcome. If you encounter bugs in Ruby/GSL, please report them on GitHub(https://github.com/SciRuby/rb-gsl/issues).

Testing and Contributing

If you wish to make contributions, run the following commands to clone and test the gem on your local machine: git clone https://github.com/SciRuby/rb-gsl.git cd rb-gsl bash test.sh

This will run tests with and without NMatrix/NArray.

Links

Documentation: https://sciruby.github.com/rb-gsl Source code: https://github.com/SciRuby/rb-gsl RubyGem: https://rubygems.org/gems/rb-gsl Bug tracker: https://github.com/SciRuby/rb-gsl/issues Travis CI: https://travis-ci.org/SciRuby/rb-gsl

Authors

rb-gsl's People

Contributors

badlamer avatar blackwinter avatar gbence avatar jc00ke avatar minad avatar v0dro avatar vaibhav-y avatar vesselinv avatar zalt50 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.