Skip to content

Instantly share code, notes, and snippets.

@arafatkatze
Last active March 5, 2016 13:45
Show Gist options
  • Save arafatkatze/3ae0cb2a5f80d3525dca to your computer and use it in GitHub Desktop.
Save arafatkatze/3ae0cb2a5f80d3525dca to your computer and use it in GitHub Desktop.
A speed test for berkowitz algorithm
require 'nmatrix'
require 'time'
def timer n
matrix = NMatrix.new([3,3], [1.0, 2.0, 1.0, -2.0, -3.0, 1.0 ,3.0, 5.0, 0.0])
now = Time.now.to_f
n.times do
matrix.charpoly
end
endd = Time.now.to_f
endd-now
end
puts timer(1000)
#0.14584898948669434
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment