carlism (owner)

Revisions

gist: 210167 Download_button fork
public
Public Clone URL: git://gist.github.com/210167.git
Embed All Files: show embed
jruby_array_math.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require 'java'
require 'jmatharray.jar'
 
id = org.math.array.LinearAlgebra.identity(4)
 
ruby_arr = [[0.25, 0.25, 0.25, 0.25],
            [0.25, 0.25, 0.25, 0.25],
            [0.25, 0.25, 0.25, 0.25],
            [0.25, 0.25, 0.25, 0.25]]
 
java_arr = ruby_arr.to_java Java::double[]
 
result = org.math.array.LinearAlgebra.plus( java_arr, id )
 
result.each do |row|
  puts row.collect{|i| i.to_s}.join(", ")
end