extendr_api::prelude::modules::lu::full_pivoting::compute

Function lu_in_place

pub fn lu_in_place<'out, I, E>(
    matrix: MatMut<'_, E>,
    row_perm: &'out mut [I],
    row_perm_inv: &'out mut [I],
    col_perm: &'out mut [I],
    col_perm_inv: &'out mut [I],
    parallelism: Parallelism<'_>,
    stack: PodStack<'_>,
    params: FullPivLuComputeParams,
) -> (FullPivLuInfo, PermRef<'out, I>, PermRef<'out, I>)
where I: Index, E: ComplexField,
Expand description

Computes the LU decomposition of the given matrix with partial pivoting, replacing the matrix with its factors in place.

The decomposition is such that: $$PAQ^\top = LU,$$ where $P$ and $Q$ are permutation matrices, $L$ is a unit lower triangular matrix, and $U$ is an upper triangular matrix.

  • $L$ is stored in the strictly lower triangular half of matrix, with an implicit unit diagonal,
  • $U$ is stored in the upper triangular half of matrix,
  • the permutation representing $P$, as well as its inverse, are stored in row_perm and row_perm_inv respectively,
  • the permutation representing $Q$, as well as its inverse, are stored in col_perm and col_perm_inv respectively.

After the function returns, row_perm (resp. col_perm) contains the order of the rows (resp. columns) after pivoting, i.e. the result is the same as computing the non-pivoted LU decomposition of the matrix matrix[row_perm, col_perm]. row_perm_inv (resp. col_perm_inv) contains its inverse permutation.

§Output

  • The number of transpositions that constitute the permutation,
  • a structure representing the permutation $P$.
  • a structure representing the permutation $Q$.

§Panics

  • Panics if the length of the row permutation slices is not equal to the number of rows of the matrix.
  • Panics if the length of the column permutation slices is not equal to the number of columns of the matrix.
  • Panics if the provided memory in stack is insufficient (see lu_in_place_req).