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

How to transpose? #8

Open
grothesque opened this issue Nov 27, 2024 · 4 comments
Open

How to transpose? #8

grothesque opened this issue Nov 27, 2024 · 4 comments

Comments

@grothesque
Copy link

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.

@fre-hu
Copy link
Owner

fre-hu commented Nov 29, 2024

See the reorder, reorder_mut and into_reordered methods. Are they what you mean?

@grothesque
Copy link
Author

Ah, I didn't find this one since I was searching for "Strided" on the documentation page for Slice.

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?

@fre-hu
Copy link
Owner

fre-hu commented Nov 29, 2024

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.

@grothesque
Copy link
Author

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants