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

Add try_into_nalgebra methods to convert to fixed-sized (and half-fixed-sized) nalgebra matrices #11

Open
elidupree opened this issue Jan 2, 2023 · 1 comment

Comments

@elidupree
Copy link

Feature request is pretty self-explanatory.

I like nalgebra's compile-time guarantees about size (just for clean coding purposes), so it would be convenient to have a single-method conversion between them, rather than having extra steps to convert from the dynamic form.

When I searched, I found this page suggesting ways to do it; presumably it would be cleanest if the method fails anytime the size doesn't match exactly, rather than silently truncating, as I think fixed_slice and fixed_rows by themselves do. (Unfortunately I haven't had the chance to try it out yet, as I'm currently bogged down in unrelated version-compatibility issues.)

@vadixidav
Copy link
Member

Sorry for the late response (a year and a half later 😅), but I believe the easiest way to do this right now would be to simply convert to a DMatrix and then go from the DMatrix to your constant sized matrix using fixed_view. This would allow you to get a fixed view of the DMatrix after conversion.

Of course, we should also be able to do this in nshare. I will leave this ticket open until we have this implemented. I do think we can add TryAsNalgebra, TryAsNalgebraMut, and TryIntoNalgebra to implement this. Note that the trait names are changing in the latest release. See #17.

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