-
Notifications
You must be signed in to change notification settings - Fork 1
How to transpose? #8
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
Comments
See the reorder, reorder_mut and into_reordered methods. Are they what you mean? |
Ah, I didn't find this one since I was searching for "Strided" on the documentation page for Yes, this solves this provides transpose, but actually for my own project I need general reordering of dimensions. Technically this is possible with mdarray, right? Is it just a matter of writing a function, or would that need some reorganization of types as well? |
There are functions for general permutations also (permute/permut_mut/into_permuted). Like the view functions they are implemented for fixed rank, so you might have issues with dynamic rank. Maybe the interface for all of these should be updated in some way. Yes, you can also write a standalone function that uses View::new_unchecked with the pointer and a new mapping from StridedMapping::new. For dynamic rank you don't need any reorganization of types. |
Thanks! IMHO the view/permute interface should be either (eventually) updated, or the dynamic rank removed. It feels incomplete in the current state. See #7 for my thoughts. No idea if/how C++ mdarray handles the dynamic rank case. (BTW I hate to use the term rank for number of dimensions, because for me the rank of a matrix is something different. But I see that C++ mdarray uses the same term, and also it's compact.) |
I've made one more commit where the permutation can be dynamic, and also axis arguments in other functions. This simplifies the typical case with dynamic dimensions and is more aligned with ndarray. There are also axis index functions for simple views, which work with dynamic rank. Hopefully this should improve useability. C++ mdarray does not support dynamic rank. |
With the updated |
Yes I think so, I will close it. I'm not sure what you mean with static arrays, but the permutation must be an IntoShape (i.e Dim tuple, [usize; N], &[usize] or similar). |
I meant what you answered in #6 (comment). Thanks. |
Having used How about renaming If “transpose” is not acceptable, how about “reverse_axes”, or “reverse_dims”, or something like that? Or just “reverse”, but IMHO that could be confused with reversing the order of entries inside the array. (I do think that “transpose” is clearer, though.) If it has to remain |
I agree, reorder is not so good name. I was unsure how to define the transposition operation, but it is probably best to follow the convention in Numpy and rename reorder to transpose. |
Fixed, see latest commit. |
Thanks! |
In current mdarray, is it possible to perform a (generalized) transpose operation, i.e. change the order of dimensions without copying the data?
Since a strided layout is supported this should be technically possible.
The text was updated successfully, but these errors were encountered: