Skip to content
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

Allow offset indices in some linear algebra #43552

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mcabbott
Copy link
Contributor

@mcabbott mcabbott commented Dec 26, 2021

This wants to make A * B work with OffsetArrays with minimal changes. The easy part is always to call similar(..., axes(A), ...) and never size.

The messier part is that it adapts the fallback generic_matmatmul! to allow offsets. The plan would be never to hit that fallback, by adding a method generic_matmatmul!(C::OffsetArray, ...) which removes offsets, and then calls mul!. That will allow an offset adjoint strided array (etc) will dispatch to the right place, after the offset is removed, without duplication or ambiguities. So perhaps the fallback need not exist?

Third, if we want to un-wrap the OffsetArrays and call mul! again, then we need α,β not MulAdd(α,β). I thought that the extra stage (and instability?) of making that twice was causing an extra allocation, so I added a step to call generic_matmatmul! without it, first. This does not seem to remove the allocaiton but might be the right thing to do anyway.

Finally, it might also be worth making generic_matmatmul! accept functions like adjoint instead of characters 'C'. In many cases this information is in the type domain when it is called, but α,β are not. (Last commit which does this unfortunately adds an ambiguity, right now.)

@dkarrasch dkarrasch added the domain:linear algebra Linear algebra label Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants