Skip to main content

rrlu_pivots

Function rrlu_pivots 

Source
pub fn rrlu_pivots<T: Scalar>(
    a: Matrix<T>,
    options: Option<RrLUOptions>,
) -> Result<RrLUPivots>
Expand description

Select rrLU pivots without constructing the triangular factors.

Consumes the column-major matrix a (its storage is reused for the in-place elimination) and returns the selected row and column indices plus the pivot error history, using the same rank and tolerance rules as rrlu_mut. The trailing pivot_errors entry is the maximum remaining residual after a rank cap, so the sequence matches rrlu_mut’s pivot_errors exactly.

§Errors

Returns MatrixCIError::InvalidArgument if the matrix shape product overflows usize, its backing storage length does not match the shape, a tolerance is negative or non-finite, or an input entry is infinite. Returns MatrixCIError::NaNEncountered if an input entry or the remaining residual is NaN.

§Examples

use tensor4all_core::{matrixlu::rrlu_pivots, RrLUOptions};
use tensor4all_tensorbackend::from_vec2d;

let a = from_vec2d(vec![
    vec![1.0_f64, 0.0],
    vec![0.0, 2.0],
]);
// The first pivot is the largest-magnitude entry, at (1, 1).
let pivots = rrlu_pivots(a, Some(RrLUOptions::default())).unwrap();
assert_eq!(pivots.rank, 2);
assert_eq!(pivots.row_indices, vec![1, 0]);
assert_eq!(pivots.col_indices, vec![1, 0]);
assert_eq!(pivots.pivot_errors, vec![2.0, 1.0, 0.0]);