Displaying 1 result from an estimated 1 matches for "diaglike".
2015 May 04
2
Why is the diag function so slow (for extraction)?
...292.953 441.7045 345.9400 637.506
706.860 10
Looking in the diag() function, I suspect the fault is mostly due to its
core operation of c(m)[v], where v is the vector in the "vec" benchmark
above. This code seems to confirm it:
v <- (1:nc-1L)*nc+1:nc
microbenchmark(diaglike=c(m)[v],vec=m[v])
# Unit: microseconds
# expr min lq mean median uq
max neval
# diaglike 579224.436 664853.7450 720372.8105 712649.706 767281.5070
931976.707 100
# vec 334.843 339.8365 568.7808 646.799 663.5825
1445.067 100...