diff --git a/src/linalg/decomposition.rs b/src/linalg/decomposition.rs index e952f18b..c72babf3 100644 --- a/src/linalg/decomposition.rs +++ b/src/linalg/decomposition.rs @@ -188,13 +188,37 @@ impl> Matrix { SVD::try_new_unordered(self.into_owned(), compute_u, compute_v, eps, max_niter) } - /// Attempts to compute the Polar Decomposition of a `matrix` (indirectly uses SVD) + /// Computes the Polar Decomposition of a `matrix` (indirectly uses SVD). + pub fn polar(self) -> (OMatrix, OMatrix) + where + R: DimMin, + DimMinimum: DimSub, // for Bidiagonal. + DefaultAllocator: Allocator + + Allocator, R> + + Allocator> + + Allocator + + Allocator, DimMinimum> + + Allocator + + Allocator + + Allocator, U1>> + + Allocator, C> + + Allocator> + + Allocator> + + Allocator> + + Allocator, U1>>, + { + SVD::new_unordered(self.into_owned(), true, true) + .to_polar() + .unwrap() + } + + /// Attempts to compute the Polar Decomposition of a `matrix` (indirectly uses SVD). /// /// # Arguments /// - /// * `eps` − tolerance used to determine when a value converged to 0. - /// * `max_niter` − maximum total number of iterations performed by the algorithm - pub fn polar( + /// * `eps` − tolerance used to determine when a value converged to 0 when computing the SVD. + /// * `max_niter` − maximum total number of iterations performed by the SVD computation algorithm. + pub fn try_polar( self, eps: T::RealField, max_niter: usize, diff --git a/src/linalg/svd.rs b/src/linalg/svd.rs index 70ab68a8..3f945a65 100644 --- a/src/linalg/svd.rs +++ b/src/linalg/svd.rs @@ -642,10 +642,10 @@ where } } - /// converts SVD results to Polar decomposition form of the original Matrix - /// A = P' * U + /// converts SVD results to Polar decomposition form of the original Matrix: `A = P' * U`. + /// /// The polar decomposition used here is Left Polar Decomposition (or Reverse Polar Decomposition) - /// Returns None if the SVD hasn't been calculated + /// Returns None if the singular vectors of the SVD haven't been calculated pub fn to_polar(&self) -> Option<(OMatrix, OMatrix)> where DefaultAllocator: Allocator //result