Skip to content

[Rcpp-devel] Speed of RCppEigen Cholesky decomposition on sparse matrix (Serguei Sokol)

2 messages · Dmitriy Selivanov, Serguei Sokol

#
But adding 0 to a sparse matrix is expensive operation. It doesn't look
fair to include it to benchmark.

??, 27 ????. 2018 ?., 20:07 rcpp-devel-request at lists.r-forge.r-project.org:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20181127/20f79db6/attachment-0001.html>
#
Le 27/11/2018 ? 17:57, Dmitriy Selivanov a ?crit?:
It is true that adding 0 comes at some cost. But qualifying it expensive 
or not is kind of subjective opinion. Let see how much does it cost:

system.time(replicate(10, C+0.))
#utilisateur     syst?me      ?coul?
#      0.017       0.030       0.047

So, in my opinion 0.017 s is negligible time laps compared to 5 or even 
3 s needed for 10 matrix decompositions. And someone else could say 
"it's important".

Anyhow, the goal was to show that Matrix::chol does only 1 decomposition 
not 10) while Eigen did all 10 decompositions, and not to thoroughly 
compare performances of two methods. The bias detected in the original 
test was much higher than the bias induced by adding 0.

Moreover, if adding 0 would be really a problem, one could easily 
exclude it from time accounting:
sum(sapply(1:10, function(i) {C=C+0.; system.time(chol(C))[1]}))
#[1] 4.488
sum(sapply(1:10, function(i) {C=C+0.; system.time(CholSparse(C))[1]}))
#[1] 3.341

and once more (to have an idea about time variability)

sum(sapply(1:10, function(i) {C=C+0.; system.time(CholSparse(C))[1]}))
#[1] 3.481

The conclusion remains the same. We see also that time variability is 
almost 10 fold higher than time needed to add 0. So I conclude that 
adding 0 did not perturbed so much the fairness of the test.

Best,
Serguei.