5.10. Matrix Manipulation
If you want to deal with numerical matrices, the standard library matrix is for you. This actually defines two separate classes, Matrix and Vector.
You should also be aware of the excellent NArray library by Masahiro Tanaka (which can be found at www.rubyforge.org). This is not a standard library but is well-known and very useful. If you have speed requirements, if you have specific data representation needs, or if you need capabilities such as Fast Fourier Transform, you should definitely look into this package. For most general purposes, however, the standard matrix library should suffice, and that is what we cover here.
To create a matrix, we naturally use a class-level method. There are multiple ways to do this. ...
Get The Ruby Way: Solutions and Techniques in Ruby Programming, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.