Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Vector and Matrix Math in Ruby

By Peter Cooper / May 30, 2006

NArray is an Numerical N-dimensional Array class. Supported element types are 1/2/4-byte Integer, single/double-precision Real/Complex, and Ruby Object. This extension library incorporates fast calculation and easy manipulation of large numerical arrays into the Ruby language.

It's impressive stuff, if you can understand the math. NArray lets you create arrays with any number of dimensions, and gives you methods that let you perform complex matrix math. There are some great demonstrations, including image resizing and image smoothing with the class. Or how about the Game of Life in under 40 lines of code?

Other Posts to Enjoy

Twitter Mentions