forked from translunar/nmatrix
-
Notifications
You must be signed in to change notification settings - Fork 134
Closed
Labels
Description
While porting Statsample-GLM form Matrix to NMatrix I found to_a is taking a lot of time than it should and in fact it is as the following benchmark shows:
require 'benchmark'
require 'matrix'
require 'nmatrix'
m = Matrix.zero 1000 ;
n = NMatrix.new [1000, 1000], [0]*10**6
Benchmark.bm do |x|
x.report "Matrix to_a" do
10.times { m.to_a }
end
x.report "NMatrix to_a" do
10.times { n.to_a }
end
end
user system total real
Matrix to_a 0.010000 0.000000 0.010000 ( 0.009627)
NMatrix to_a 4.680000 0.080000 4.760000 ( 4.777082)Improvement in to_a might solve the issue in SciRuby/statsample-glm#36
v0dro