hidmic / ltitop

Linear Time Invariant Topology Optimization Toolkit
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Use Python AST subset for algorithm definition #9

Open hidmic opened 2 years ago

hidmic commented 2 years ago

Rationale

Alternative to #2. Algorithms are defined via sympy symbolic expressions solely to enable term permutation in summations. But such permutations would also be possible in a Python AST.

Why not ast.parse a function definition to extract its AST? Some feature (i.e. node) pruning is necessary as most Python features are way beyond scope and would be near impossible to transfer upon C or HDL generation, but otherwise this approach would greatly simplify algorithm definitions and potentially boost speed -- sympy is just too slow.

Definition of done

Additional considerations

Generators and list comprehensions would be super useful when defining sums and products, but, if supported, these have to be expanded upon AST extraction (or term permutation will not be possible). Also, the feature set must be kept at a minimum -- enough to guarantee that algorithms are simply describing operations on a data-flow (or code generation may not be possible).