-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decide on high level looping constructs #3
Comments
Not sure if this is of any value for you, but I managed (very hackishly) make this work: x[i] = (a[i]/3-1)**i + c here: https://github.com/bjodah/pycodeexport/blob/master/examples/loops_main.py (uses mako template's to recursivesly print loops) |
mmmboy, that's complicated. I'm actually planning on having as little magic in this as possible. I'm looking more for expressive ways to define iterations in SymPy. These will then be converted to instances of Enclosed in a higher looping construct though, the indices are nice. Something like:
isn't too bad. I'd like to really get these designed in the most expressive and usable way possible though, so we don't have to redo them again... |
I'm all for less magic! (that example of mine was a horrible hack...) No, I'm not a fan of the tensor contraction either - to me it's an exception and should be handled by the tensor module, not by code printers. I really like your approach with a proper tree structure for this with appropriate nodes! |
My advice here would be to use non-code generation specific things whenever possible. That is, they should be done in a mathematically general way whenever it makes sense. For example, "sum of an array" makes mathematical sense outside of code generation. So I would implement a way to do that in SymPy in general, and then write code printers for it. Raw loop constructs, like I agree that tensor looping is not the way to go. Not all loops are tensor loops, and not everyone thinks in terms of tensors, or has even been taught that way (it's not a trivial way of thinking to learn if you haven't done it before). |
So far what I'd like to implement is:
Functional Looping
Map
Filter
Reduce
Mathematical Looping
Sum
(not like sympy's sum, more like python's sum)Prod
(likeSum
, but with*
, not+
)Ideally, sympy's
Sum
could also work, so maybe we should havesum
instead, that returns asympy.Sum
object, with the iteration setup properly.The text was updated successfully, but these errors were encountered: