polar_decomposition

Function polar_decomposition 

Source
pub fn polar_decomposition<A>(
    a: &ArrayView2<'_, A>,
    compute_p: bool,
) -> LinalgResult<(Array2<A>, Option<Array2<A>>)>
where A: Float + NumAssign + Debug + Display + ScalarOperand + Sum + Send + Sync + 'static,
Expand description

Polar decomposition of a matrix

Decomposes a matrix A into the product A = U * P where:

  • U is unitary (orthogonal for real matrices)
  • P is positive semidefinite

This decomposition is useful in various applications including:

  • Computing the nearest orthogonal matrix
  • Matrix square roots
  • Procrustes problems

§Arguments

  • a - Input matrix
  • compute_p - Whether to compute P (if false, only U is returned)

§Returns

  • Tuple (U, Option

    ) where U is unitary and P is positive semidefinite

§Example

use scirs2_core::ndarray::array;
use scirs2_linalg::decomposition_advanced::polar_decomposition;

let a = array![[1.0, 2.0], [3.0, 4.0]];
let (u, p) = polar_decomposition(&a.view(), true).unwrap();
assert!(p.is_some());