Home: dennou ruby home page
Japanese version is here.

Ruby-LAPACK

- a Ruby wrapper of LAPACK -



What's Ruby-LAPACK

Ruby-LAPACK is a Ruby wrapper of LAPACK.


Download

the latest version is 1.6 [12 May 2014]

gem

# gem install ruby-lapack

source files

ruby-lapack-1.6.tar.gz
ruby-lapack-1.6.tar.bz2

You can also get from git repository

% git clone http://ruby.gfd-dennou.org/products/ruby-lapack/ruby-lapack.git


Requires


Usage

You need require numru/lapack to use Ruby-LAPACK

require 'numru/lapack'

Each subroutine/function is defined as module function of NumRu::Lapack.

returns = NumRu::Lapack.method_name(args)
In the arguments and returns, array (Matrix) is NArray object. The order of Matrix dimensions is the same as the notation of mathematics: x_ij => x[i-1,j-1].
If you call methods with the argument of :help=>true, or :usage=>true, help or usage message will be printed, respectively.
NumRu::Lapack.method_name(:help => true)
NumRu::Lapack.method_name(:usage => true)


Documents

Documents for individual methods are here


Example

DSYEVR: Compultes selected eigenvalues, and optinally, eigenvectors of a real symmetric matrix.
The following script calculats the leading eigenvalue and corresponding eigenvector of the matrix (x_11 = 1, x_12 = x_21 = 2, x_22 = 3).
Ruby method is NumRu::Lapack.dsyevr.

jobz = "V"
range = "I"
uplo = "U"
a = NArray[[1,2],[2,3]]
vl =  vu = 0 # not be used in this example
il = 1
iu = 2
abstol = 0.0

m, w, z, isuppz, work, iwork, info, a = NumRu::Lapack.dsyevr(jobz, range, uplo, a, vl, vu, il, iu, abstol)
The corresponding FORTRAN subroutine is DSYEVR.
SUBROUTINE DSYEVR(JOBZ, RANGE, UPLO, N, A, LDA, VL, IL, IU, ABSTOL, M, W, Z, LDZ, ISUPPZ, WORK, LWORK, IWORK, LIWORK, INFO)
# JOBZ(input), RANGE(input), UPLO(input)
# N(input), A(input/output), LDA(input)
# VL(input), IL(input), IU(input), ABSTOL(input)
# M(output), W(output), Z(output), LDZ(input), ISUPPZ(output)
# WORK(workspace/output), LWORK(input), IWORK(workspace/output), LIWORK(input)
# INFO(output)
N is order of the matrix A, LDA is size of the leading dimension of the array A, LDZ is size of the leading dimension of the array Z, LWORK is size of the array WORK, and LIWORK is size of the array IWORK.