koheiw / proxyC

R package for large-scale similarity/distance computation
GNU General Public License v3.0
29 stars 6 forks source link

Add sparse = TRUE #53

Closed koheiw closed 4 months ago

koheiw commented 4 months ago

Add sparse = TRUE. This is a new branch for #38.

koheiw commented 4 months ago
> require(Matrix)
> mat <- rsparsematrix(1000, 10, 0.5)
> 
> print(object.size(dist(mat, sparse = TRUE)), unit = "Mb")
7.6 Mb
> print(object.size(dist(mat, sparse = FALSE)), unit = "Mb")
3.8 Mb
> 
> microbenchmark::microbenchmark(
+     dist(mat, sparse = TRUE),
+     dist(mat, sparse = FALSE),
+ times = 10)
Unit: milliseconds
                      expr     min      lq     mean  median      uq     max neval
  dist(mat, sparse = TRUE) 26.4083 26.6380 26.89330 26.8313 27.1955 27.6437    10
 dist(mat, sparse = FALSE) 25.3591 25.8587 27.59053 26.1021 26.3652 41.3386    10
koheiw commented 4 months ago

@rcannood can you review?

koheiw commented 4 months ago

@rcannood thank you!