f# - slow matrix operations compared to R -


the following calculation runs slower in r:

let result = (x.transpose() * b * x).inverse() * (x.transpose() * b) * e // 4 seconds on machine 

or this:

let result = (x.transpose() * b * x).qr().solve((x.transpose() * b) * e) 

where

open mathnet.numerics.linearalgebra  let x = densematrix.init 2000 7 (fun j -> 1.) let b = sparsematrix.ofdiag (vector [for in 0 .. 1999 yield 1.]) let e = densematrix.init 2000 1 (fun j -> 1.) 

in r however, same calculation can achieved via following takes couple hundred milliseconds:

result <- solve(crossprod(x,b*x), crossprod(x,b*e)) // less 200ms 

is there way can speed f# calculation?

[edit] btw, sparsematrix seems bottleneck. when densematrix used instead, there seems massive speedup.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -