Git Product home page Git Product logo

nmatrix's Introduction

NMatrix

Fast Numerical Linear Algebra Library for Ruby

<img src=https://travis-ci.org/SciRuby/nmatrix.png>

<img src=“https://codeclimate.com/github/SciRuby/nmatrix.png” />

Description

NMatrix is a fast numerical linear algebra library for Ruby, with dense and sparse matrices, written mostly in C and C++. It is part of the SciRuby project.

NMatrix was inspired by NArray, by Masahiro Tanaka.

Installation

To install the latest stable version:

gem install nmatrix --pre

However, you will need to install ATLAS with CBLAS (C interface to BLAS) first. Detailed directions can be found here. The requirements for NMatrix are:

  • ATLAS, preferably with CLAPACK (see here for details)

  • a version of GCC or clang which supports C++0x or C++11

  • Ruby 1.9.3+

  • packable 1.3.5 (used for I/O)

If you want to obtain the latest (development) code, you should generally do:

git clone https://github.com/SciRuby/nmatrix.git
cd nmatrix/
bundle install
bundle exec rake compile
bundle exec rake repackage
gem install pkg/nmatrix-0.1.0.rc5.gem

Detailed instructions are available for Mac and Linux. We are currently working on Mavericks (Mac OS X) installation instructions, but in general, you’ll need Homebrew and should probably use +brew install gcc48+ instead of using the install script.

Documentation

If you have a suggestion or want to add documentation for any class or method in NMatrix, please open an issue or send a pull request with the changes.

You can find the complete API documentation on our website.

Examples

Create a new NMatrix from a ruby Array:

>> require 'nmatrix'
>> NMatrix.new([2, 3], [0, 1, 2, 3, 4, 5], dtype: :int64)
=> [
    [0, 1, 2],
    [3, 4, 5]
   ]

Create a new NMatrix using the N shortcut:

>> m = N[ [2, 3, 4], [7, 8, 9] ]
=> [
    [2, 3, 4],
    [7, 8, 9]
   ]
>> m.inspect
=> #<NMatrix:0x007f8e121b6cf8shape:[2,3] dtype:int32 stype:dense>

The above output requires that you have a pretty-print-enabled console such as Pry; otherwise, you’ll see the output given by inspect.

If you want to learn more about how to create a matrix, read the guide in our wiki.

Again, you can find the complete API documentation on our website.

Developers

Read the instructions in CONTRIBUTING.md if you want to help NMatrix.

Features

The following features exist in the current version of NMatrix (0.1.0.rc1):

  • Matrix and vector storage containers: dense, yale, list (more to come)

  • Data types: byte (uint8), int8, int16, int32, int64, float32, float64, complex64, complex128, rational64, rational128, Ruby object

  • Interconversion between storage and data types

  • Element-wise and right-hand-scalar operations and comparisons for all matrix types

  • Matrix-matrix multiplication for dense (with and without ATLAS) and yale

  • Matrix-vector multiplication for dense (with and without ATLAS)

  • Lots of enumerators (each, each_with_indices, each_row, each_column, each_rank, map, etc.)

  • Matrix slicing by copy and reference (for dense, yale, and list)

  • Native reading and writing of dense and yale matrices

    • Optional compression for dense matrices with symmetry or triangularity: symmetric, skew, hermitian, upper, lower

  • Input/output:

    • Matlab .MAT v5 file input

    • MatrixMarket file input/output

    • Harwell-Boeing and Fortran file input

    • Point Cloud Library PCD file input

  • C and C++ API

  • BLAS internal implementations (no library) and ATLAS (with library) access:

    • Level 1: xROT, xROTG (BLAS dtypes only), xASUM, xNRM2, IxAMAX

    • Level 2: xGEMV

    • Level 3: xGEMM, xTRSM

  • LAPACK ATLAS access:

    • xGETRF, xGETRI, xGETRS, xGESV (Gaussian elimination)

    • xPOTRF, xPOTRI, xPOTRS, xPOSV (Cholesky factorization)

    • xLASWP, xSCAL, xLAUUM

  • LAPACK-less internal implementations (no LAPACK needed and working on non-BLAS dtypes):

    • xGETRF

    • xLASWP, xSCAL

    • xLAUUM (no LAPACK needed, but BLAS dtypes only)

  • LAPACK (non-ATLAS) access:

    • xGESVD, xGESDD (singular value decomposition)

    • xGEEV (eigenvalue decomposition of a asymmetric square matrices)

  • LU decomposition

  • Matrix inversions

  • Determinant calculation for BLAS dtypes

  • Traces

  • Ruby/GSL interoperability (requires SciRuby’s fork of rb-gsl)

  • slice assignments, e.g.,

    x[1..3,0..4] = some_other_matrix
    

Planned Features (Short-to-Medium Term)

See the issues tracker for a list of planned features or to request new ones.

License

Copyright © 2012–15, John Woods and the Ruby Science Foundation.

All rights reserved.

NMatrix, along with SciRuby, is licensed under the BSD 2-clause license. See LICENSE.txt for details.

Donations

Support a SciRuby Fellow:

<img src=http://pledgie.com/campaigns/15783.png?skin_name=chrome>

nmatrix's People

Contributors

translunar avatar chriswailes avatar cjfuller avatar agarie avatar ryanmt avatar atimin avatar duggiefresh avatar andrewcsmith avatar rve avatar v0dro avatar rajatkapoor avatar sheerun avatar erik avatar masaomi avatar terrencekhng avatar andrioni avatar dustalov avatar jtprince avatar kcerb avatar kevinhughes27 avatar mvz avatar matt-liu avatar foobar2016 avatar yoongkang 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.