Implementing Arrays and Tensors with Ruby and libJIT
Implementing numerical algorithms typically demands a trade-off between readability and performance of the code. However the way we write programs affects our understanding of the problems we are trying to solve.
Statically typed languages represent numbers and arrays with primitive types. This means that the most relevant data types for signal processing have only very limited capabilities in those languages. The dynamically typed programming language Ruby is pure object-oriented and makes it easy to implement algorithms which will work on arrays with elements of any numerical type. However the current Ruby interpreter is lacking in terms of processing speed.
This paper presents a Ruby extension which makes use of the libJIT just-in-time compiler. Dynamical typing is used to analyze closures and translate corresponding element-wise operations for arrays to machine code. The same approach is used to compile tensor operations thus allowing the use of Einstein notation in Ruby.