symforce-org / symforce

Fast symbolic computation, code generation, and nonlinear optimization for robotics
https://symforce.org
Apache License 2.0
1.41k stars 145 forks source link

Add function specific overwrites to sympy CPP printer #225

Closed RoyVorster closed 2 years ago

RoyVorster commented 2 years ago

This allows users to overwrite a specific sympy function with their own implementation, an example config would look like:

config = codegen.CppConfig(override_methods={sym.sin: "very_fast_sin"}, extra_headers=["very_fast_math.h"])

@aaron-skydio I'm not sure how this would work with symengine expressions. Feel free to modify, this is just a superquick proof of concept but it does what I want for sympy expressions.