pub fn rows_to_u_matrix<T: Scalar>(
r: &mut Matrix<T>,
p: &Matrix<T>,
_left_orthogonal: bool,
) -> Result<()>Expand description
Convert R matrix to solve X * U = B given pivot matrix P
Modifies r in place so that the rows satisfy the triangular
system defined by p. The matrix r must have at least p.nrows()
rows.
§Errors
Returns MatrixCIError::InvalidArgument when p is not square or
r has too few rows, and MatrixCIError::SingularMatrix for a zero
diagonal pivot.
§Examples
use tensor4all_core::matrixlu::rows_to_u_matrix;
use tensor4all_tensorbackend::from_vec2d;
// Lower-triangular P (2x2)
let p = from_vec2d(vec![
vec![2.0_f64, 0.0],
vec![1.0, 3.0],
]);
// r has 2 rows (nrows >= p.nrows()), 3 columns
let mut r = from_vec2d(vec![
vec![4.0_f64, 6.0, 8.0],
vec![5.0, 9.0, 7.0],
]);
rows_to_u_matrix(&mut r, &p, true).unwrap();
// After processing: r[0,:] was divided by p[0,0]=2
assert!((r[[0, 0]] - 2.0).abs() < 1e-10);
assert!((r[[0, 1]] - 3.0).abs() < 1e-10);
assert!((r[[0, 2]] - 4.0).abs() < 1e-10);