-
Notifications
You must be signed in to change notification settings - Fork 147
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
Adding "algebraic expansions" ? #351
Comments
Ah sorry, I realize now that in reducing the thing I'm really after to the above example, I actually created something that has a trivial solution, that is, just interpolate The reason for the seemingly convoluted ways I was trying to go about it above is because really I want the algebraically expanded expression to also be broadcast over, and since you can't currently use loop fusion in the generated body, I was trying to get around that. I suppose this means it'd be quite doable to have this type of feature in StaticArrays. |
I suspect we already generate very good code for the original example so TBH I'm not really sure what's actionable here. But if you've got specific benchmarks where we should be doing better, please do share :-) |
I've been toying with adding an "algebraic expansion" feature to StaticArrays and was curious for feedback / ideas. Sorry if this is just noise, feel free to close, but I thought people working on this package would be both interested and knowledgeable on this topic. So, by algebraic expansion I mean, suppose I'm doing the matrix operation,
Say these are all dimension 2, then it would be really cool if somehow we could evaluate this most efficiently, which is just to do,
as opposed to the way its currently done which uses temporary arrays.
If you define a new operator, say
⨳
, and define that broadcasting over this operator does the aforementioed expansion, i.e. above you would write@. x' ⨳ A ⨳ y
, then in theory you could overload broadcast,By making it generated, it should be pretty easy to maintain type-stability. The problem, however, is how to evaluate my
new_func_expr
(which is an Expr) and use it inside the generated body. Turns out, Julia works pretty hard to prevent me from doing this :) (for good reason, I imagine) Here's three failed attempts on a simplified example,This is basically where I am at thinking about this. I'm curious if anyone has other ideas how to get around this? Or maybe how to write a non-
@generated
version that could be type-stable?The text was updated successfully, but these errors were encountered: