Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment