statnet / ergm.multi

Fit, Simulate and Diagnose Exponential-Family Models for Multiple or Multilayer Networks
Other
14 stars 1 forks source link

Use integer arithmetic in layer logic C code rather than floating point? #17

Closed krivit closed 1 year ago

krivit commented 2 years ago

Right now, both commands and intermediate results are encoded using the default R numeric type (C double). Using int instead appears to reduce the computing cost of the core layer logic code by about 15%. The cost is that any arithmetic done on the layer logic formulas can only involve integers and will resolve as C integer arithmetic. I am not aware of any applications in which floating point arithmetic might be useful, but if we ever implement a valued version of layer logic, it would be needed.

krivit commented 2 years ago

A simulation test actually suggests a more than 20% speedup overall, more than the profiler. I wonder why.