Matrix polar decomposition

Hey! First, thanks for the awesome libraries!

I need the matricial polar decompositions for a small side project. I could not find a ready-make implementation in nalgebra. It is a simple enough algorithm to implement, given the SVD decomposition, which is already available in nalgebra.

So, this seems like an ideal first contribution to this amazing crate. I am not a specialist in Rust, so the code will require a few rounds of review before being merged.

Thus, I think that first I should ask if there is interest in having the decomposition in the codebase, and if there is interest/availability in mentoring newcomers to the community.


Yes, adding this would be a useful contribution! I’d suggest to start by opening an issue on the github repository describing your goals. Then you can open a PR as your progress and ask questions there. I, and others will take a look, and don’t hesitate to ping me (@sebcrozet) directly if you don’t get answers for a few days. Also don’t hesitate to ask questions on our discord server.

The one thing you will likely struggle the most with are the trait bounds. So I suggest you start by implementing this for dynamics matrices DMatrix<N> only. This will help focus on the decomposition algorithm itself. Then we will see how to generalize this so it supports statically-sized matrices as well.


Thanks for the positive feedback! I will as recommended.

By the way, I started coding it already, and you were completely right! Finding the correct trait bounds was short of impossible. Thanks for the tip of first implementing the algorithm just for DMatrix<N>. I will do those changes and check. However, this interlude with the traits got me interested. Is there any part of the documentation dealing with this, in case I missed something?

Not really unfortunately. That describes shortly how to use nalgebra in a generic way (but it is not very detailed). Though there is no documentation on how to add new dimensionally-generic features to nalgebra itself.