kaneplusplus / bigmemory

126 stars 24 forks source link

Optimize int writes #85

Closed phaverty closed 6 years ago

phaverty commented 6 years ago

Uses an Rcpp function from Florian Prive to convert an incoming matrix to integer type, checking to see if any values are unexpectedly changed. Speeds up writing big integer matrices by 5X and fixes #84

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-5.07%) to 54.494% when pulling d6ad7d3faa7dc14083784c2a8ad7aa007327ceee on phaverty:optimize_int_writes into 9d2c01b49b8f0f7fd51972f65771b4cd5b8cc486 on kaneplusplus:master.

privefl commented 6 years ago

@phaverty Note that when converting e.g. from double to integer, for missing values you get: nan -> -2147483648. So, you'll get a warning even if there is no actual loss of precision. You could replace nv[i] != res[i] by res[i] != nv[i] && res[i] != NA_INTEGER to overcome this problem (I think without significant loss in performance).