-
Notifications
You must be signed in to change notification settings - Fork 133
NMatrix for JRuby
NMatrix is supported on Ruby-MRI as well as JRuby.
-
dtype
=>float64
-
stype
=>dense
- The frontend exclusive to NMatrix-JRuby resides in
lib/nmatrix/jruby
. - The backend of NMatrix-JRuby resides in
ext/nmatrix_java
. The backend is built by building a wrapper around Apache Commons Math.
NMatrix object can be represented as:
@s
stores elements, @shape
stores the shape of the matrix, while @dtype
and @stype
store the data type and storage type respectively.
Linear algebra is mostly about two-dimensional matrices. In NMatrix, when performing calculations in a two-dimensional matrix, a one-dimensional array is converted to a two-dimensional matrix. A two-dimensional matrix is stored in the JRuby implementation as a BlockRealMatrix
or Array2DRowRealMatrix
.
To learn how to call Java code on JRuby, have a look at this resource..
-
Memory Usage and Garbage Collection: A scientific library is memory intensive and hence, every step counts. The JRuby interpreter doesn’t need to dynamically guess the data type and uses less memory, typically around one-tenth of it. If the memory is properly utilized, when the GC kicks in, the GC has to clear less used memory space.
-
Speed: Using java method greatly improves the speed — by around 1000 times, when compared to using the Ruby method.