Guest User

Untitled

a guest
Jan 12th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. require 'matrix'
  3.  
  4. [16,64,256,257,512,111,229].each do |d|
  5. a = Matrix.build(d, d){ rand(2)-1 }
  6. b = Matrix.build(d, d){ rand(2)-1 }
  7. open('mat-%d' % d, 'w'){|f| f.write (a.to_a.flatten + b.to_a.flatten).join("\n") }
  8. c = a * b
  9. open('mat-%d-out' % d, 'w'){|f| f.write (1..d).map{|i| c[i,i] } }
  10. end
Add Comment
Please, Sign In to add comment