zoomy_core.symsolver.core#
The machinery under the solver templates: Block and Effect names in a sympy
graph, scoped common-subexpression planning, and the Python and C++ printers. A
template runs once on sympy symbols and a printer turns the resulting graph into
source code.
Module Contents#
Classes#
Opaque building block; every backend supplies a callable of this name. |
|
Component |
|
|
|
|
|
|
|
|
|
Base of the graph nodes created by |
|
Declared effect, |
|
Python family: numpy and JAX print the same text. |
|
C++ family: foam and AMReX print the same text, with the runtime’s free functions
|
Functions#
Return |
|
Run-time loop with an explicit carry: |
|
Run-time branch; only the taken branch executes. |
|
Solve |
|
Solve |
|
Return the sorted names every backend runtime must define (blocks and effects). |
API#
- class zoomy_core.symsolver.core.Block#
Bases:
sympy.FunctionOpaque building block; every backend supplies a callable of this name.
- class zoomy_core.symsolver.core.Get#
Bases:
sympy.FunctionComponent
iof a block that returns several values.- nargs#
2
- class zoomy_core.symsolver.core.while_loop#
Bases:
zoomy_core.symsolver.core.Block(cond, body, init) -> final carry; cond and body take the carry.
- class zoomy_core.symsolver.core.cond#
Bases:
zoomy_core.symsolver.core.Block(pred, then, other) -> value; the branches take no arguments.
- class zoomy_core.symsolver.core.root#
Bases:
zoomy_core.symsolver.core.Block(residual, x0) -> xwithresidual(x) = 0.
- class zoomy_core.symsolver.core.linsolve#
Bases:
zoomy_core.symsolver.core.Block(matvec, b) -> xwithmatvec(x) = b, solved matrix-free (restarted GMRES by default).References
Saad, Schultz 1986, https://doi.org/10.1137/0907058
- class zoomy_core.symsolver.core.EffectNode#
Bases:
zoomy_core.symsolver.core.BlockBase of the graph nodes created by
Effect.
- class zoomy_core.symsolver.core.Effect(n_out=0)#
Declared effect,
name = Effect(n_out)inside a namespace class; the backend name is<namespace>_<attr>. It receives the order token first and returns(token, *outputs).Initialization
n_out: number of values the effect returns.
- zoomy_core.symsolver.core.unpack(call, n)#
Return
nGetnodes for the components of a multi-outputcall.
- zoomy_core.symsolver.core.While(c, body, init)#
Run-time loop with an explicit carry:
body(*carry) -> carry; returns the final carry.
- zoomy_core.symsolver.core.Cond(pred, then, other)#
Run-time branch; only the taken branch executes.
- zoomy_core.symsolver.core.Root(residual, x0)#
Solve
residual(x) = 0fromx0at run time.
- zoomy_core.symsolver.core.LinSolve(matvec, b)#
Solve
matvec(x) = bat run time (seelinsolve).
- class zoomy_core.symsolver.core.PyPrinter#
Bases:
zoomy_core.symsolver.core._Common,sympy.printing.pycode.PythonCodePrinterPython family: numpy and JAX print the same text.
Initialization
Allow unknown (block) functions and unqualified module names.
- destructure#
True
- assign_many(names, rhs, ind)#
Tuple-unpacking assignment.
- assign(nm, rhs, ind)#
Assignment statement.
- lambda_def(nm, args, body, ret, ind)#
Nested
defreturningret.
- proc_def(name, args, body, ret)#
Top-level
defreturningret.
- class zoomy_core.symsolver.core.CxxPrinter#
Bases:
zoomy_core.symsolver.core._Common,zoomy_core.transformation.cxx_base.CxxBaseC++ family: foam and AMReX print the same text, with the runtime’s free functions
pow/minimum/maximumand no structured bindings (C++17 lambdas cannot capture them).Initialization
Allow unknown (block) functions.
- destructure#
False
- math_namespace = <Multiline-String>#
- assign(nm, rhs, ind)#
autodeclaration.
- lambda_def(nm, args, body, ret, ind)#
Nested
[&]lambda returningret.
- proc_def(name, args, body, ret)#
Top-level
inline autolambda returningret.
- zoomy_core.symsolver.core.contract()#
Return the sorted names every backend runtime must define (blocks and effects).