Skip to main content

lower_triangular

Function lower_triangular 

Source
pub fn lower_triangular<T: MatrixDataTrait, const SIZE: usize>(
    matrix: Matrix<T, SIZE, SIZE>,
) -> Matrix<T, SIZE, SIZE>
Expand description

Converts the given matrix to its lower triangular form and returns it.

§Type Parameters

  • T - The type of the elements in the matrix.
  • SIZE - The number of rows and columns in the matrix.

§Arguments

  • matrix - The matrix to be converted.

§Returns

A new matrix that is the lower triangular form of the given matrix.

§Example

use numberlab::structure::matrix::{Matrix, lower_triangular};

let matrix = Matrix::<i32, 3, 3>::from_array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
let lower = lower_triangular(matrix);

assert_eq!(lower, Matrix::<i32, 3, 3>::from_array([[1, 0, 0], [4, 5, 0], [7, 8, 9]]));