cms-nanoAOD / correctionlib

A generic correction library
https://cms-nanoaod.github.io/correctionlib/
BSD 3-Clause "New" or "Revised" License
16 stars 22 forks source link

Formula performance improvements #173

Open nsmith- opened 1 year ago

nsmith- commented 1 year ago

The current formula implementation walks an AST on evaluation. The AST is not optimized beforehand. We could improve this in a few ways:

A simpler solution might be to check if the formula is some regular pattern and convert it to a more specialized node. For example, we could create dedicated Horner-form polynomial evaluation nodes from formulas that are just multivariate polynomials. There is some literature on multivariate Horner forms e.g. https://arxiv.org/abs/1207.7079 and an existing python package: multivar_horner.