Skip to content

Instantly share code, notes, and snippets.

@carlism
Created October 14, 2009 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlism/210167 to your computer and use it in GitHub Desktop.
Save carlism/210167 to your computer and use it in GitHub Desktop.
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