Skip to main content

eye

Function eye 

Source
pub fn eye<T: Clone + Zero + One>(n: usize) -> Matrix<T>
Expand description

Create an n x n identity matrix.

ยงExamples

use tensor4all_tcicore::matrix::eye;

let m: tensor4all_tcicore::Matrix<f64> = eye(3);
assert_eq!(m[[0, 0]], 1.0);
assert_eq!(m[[1, 1]], 1.0);
assert_eq!(m[[0, 1]], 0.0);
assert_eq!(m[[2, 0]], 0.0);