Installing NMatrix from SciRuby

I am getting involved in the SciRuby project. One of the main sub-projects is called NMatrix. It is a library for linear algebra.

NMatrix uses some C/C++ and Fortran libraries. The installation instructions for Linux refer people to the installation pages for SciPy. To a certain degree, SciPy is a competitor to SciRuby. I think it is a bit ironic that they refer people to SciPy for instructions.

SciRuby requires two libraries called ATLAS and LAPACK. The SciPy instructions go over how to compile and install the libraries from source. I really do not like to do that. I prefer to use Ubuntu packages for C/C++ libraries as much as possible. I got it to work, and here are the steps I went through.

At the time of this writing (2012-07-31_22.27.46), I am using the precise version of Ubuntu.

I installed a couple of packages first: libatlas-dev and libatlas3gf-base. I ran

gem install nmatrix

and got a couple of errors:

Issue: # @echo linking shared-object
/usr/bin/ld: cannot find -lcblas
/usr/bin/ld: cannot find -latlas
collect2: ld returned 1 exit status

I did some googling, and I found out this is because it cannot find libraries called cblas and atlas. “ld” is the GNU linker. I had a few *so.* files in /usr. According to what I found out, ld wants the files to end with .so. For some reason, there are a lot of library files in Ubuntu that end with .so.1, or so.0. There are a few that end with .so.3gf.0. The “3gf” means they were made from Fortran source.

I found the library files by running the “locate” command:

/loneStar$ locate cblas

So the commands that I ran were

ln -s /usr/lib/ /usr/lib/
ln -s /usr/lib/atlas-base/ /usr/lib/

Then I ran

gem install nmatrix

and eventually I got this:

Building native extensions.  This could take a while...
Welcome to SciRuby: Tools for Scientific Computing in Ruby!

                     *** WARNING ***
Please be aware that NMatrix is in ALPHA status. If you're
thinking of using NMatrix to write mission critical code,
such as for driving a car or flying a space shuttle, you
may wish to choose other software (for now).

NMatrix requires a C compiler, and has been tested only
with GCC 4.6.1. We are happy to accept contributions
which improve the portability of this project.

Also required is ATLAS. Most Linux distributions and Mac
versions include ATLAS, but you may wish to compile it

More explicit instructions for NMatrix and SciRuby should
be available on the SciRuby website,, or
through our mailing list (which can be found on our web-

Thanks for trying out NMatrix! Happy coding!

Successfully installed nmatrix-0.0.1
1 gem installed
Installing ri documentation for nmatrix-0.0.1...
Installing RDoc documentation for nmatrix-0.0.1...

There aren’t any more space shuttle flights. That seems like an odd warning.

After that, I installed the pry gem, and ran this command:

pry --require nmatrix

I was able to run the commands on the NMatrix wiki on Github.

Image from Madrid Skylitzes, a 12th century manuscript of Synopsis of Histories by Greek historian John Skylitzes; manuscript housed at National Library of Spain; manuscript information here. Image from World Document Library, licensed under CC BY-NC-SA 4.0.