wrathematics / coop

Fast covariance, correlation, and cosine similarity.
Other
35 stars 6 forks source link

cosine() fails on larger sparse matrices #11

Closed chasemc closed 5 years ago

chasemc commented 5 years ago

I'm running cosine similarity using the coop package on a sparse matrix that is 4343 rows by 300 columns:

a <- read.csv("https://gist.githubusercontent.com/chasemc/713b8b0b7a67129d7a8084e2aededec3/raw/69f84bba46e479204fc27402a492a537ee10e86d/sparseMatrix.csv")
b <- as.matrix(a)
b <- Matrix::Matrix(b)
coop::cosine(b)

R crashes if 130 or more columns were being provided to coop::cosine(), but if converted to a regular matrix it works.

R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.5.3 tools_3.5.3    yaml_2.2.0    

R Version:
               _                           
platform       x86_64-w64-mingw32          
arch           x86_64                      
os             mingw32                     
system         x86_64, mingw32             
status                                     
major          3                           
minor          5.3                         
year           2019                        
month          03                          
day            11                          
svn rev        76217                       
language       R                           
version.string R version 3.5.3 (2019-03-11)
nickname       Great Truth                 
wrathematics commented 5 years ago

Thanks, should be fixed now.

chasemc commented 5 years ago

Awesome, I confirmed it's fixed for the example I provided. Thanks for the quick turnaround.