Skip to content

Instantly share code, notes, and snippets.

@serialhex
Created July 27, 2011 12:27
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 serialhex/1109251 to your computer and use it in GitHub Desktop.
Save serialhex/1109251 to your computer and use it in GitHub Desktop.
require 'narray'
# cheap & easy way to do this...
matrix = []
File.open("numbers.file") do |file|
file.each_line do |line|
ary = []
line.split(" ").each{ |n| ary << n.to_f }
matrix << ary
end
end
matrix = NArray.to_na(matrix)
[[1.0, 2.0], [3.0, 4.0]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment