opensim-org / opensim-core

SimTK OpenSim C++ libraries and command-line applications, and Java/Python wrapping.
https://opensim.stanford.edu
Apache License 2.0
758 stars 308 forks source link

Implement new `MultivariatePolynomialFunction` function evaluation algorithm to improve performance #3762

Closed nickbianco closed 2 months ago

nickbianco commented 2 months ago

Currently, MultivariatePolynomialFunction uses nested for-loops to cycle through all possible coefficients for a given multivariate polynomial. Function evaluation time could be reduced only including terms with non-zero coefficients, and by implementing a faster algorithm for evaluating polynomials (e.g., Horner's scheme using greedy algorithms).

These improvements could substantially improve performance in FunctionBasedPath, which relies on MultivariatePolynomialFunction when fitting paths with PolynomialPathFitter.