Here's an example that may be of interest that uses Sympy in the context of 
a scientific application.

This Jupyter notebook derives the defining equations for cubic spline 
coefficients (in tridiagonal matrix form), substitutes those equations into 
those for a tridiagonal solver (not derived, just taken from Wikipedia), 
and generates a templated C++ function.

https://github.com/QMCPACK/qmc_algorithms/blob/master/Wavefunctions/CubicSplineSolver.ipynb


The additional code generation bits are here:
https://github.com/QMCPACK/qmc_algorithms/blob/master/Wavefunctions/codegen_extras.py


More generally, I've been working to make a stronger connection between 
symbolic representations of expressions and the code that implements them.  
 The example here generates production code, but a less intrusive route 
(which is used more frequently) is to create values for unit testing.

So far, the process I've decided to use is to create a Jupyter notebook 
with a derivation or explanation of some expression.  The notebook is 
manually converted to a python script which is run to create the code or 
the unit tests.  This script is checked into the repository along with the 
generated code or tests.


The above notebook was converted into this script in the main code 
repository:
https://github.com/QMCPACK/qmcpack/blob/develop/src/Numerics/codegen/gen_cubic_spline_solver.py

And the generated results are stored here:
https://github.com/QMCPACK/qmcpack/blob/develop/src/Numerics/SplineSolvers.h

(The notebooks are kept in a separate repository from the main code because 
this is still experimental.  The manual conversion of the notebook to a 
standalone script is an unfortunate step, but the standalone script is 
easier to use and store for reproducibility.)

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/10d035ee-d142-4849-937f-f68084733089%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to