Function eye_sym_array

Source
pub fn eye_sym_array<T>(
    n: usize,
    format: &str,
) -> SparseResult<Box<dyn SymSparseArray<T>>>
where T: Float + Debug + Copy + 'static + Add<Output = T> + Sub<Output = T> + Mul<Output = T> + Div<Output = T>,
Expand description

Create a symmetric identity matrix

§Arguments

  • n - Matrix size (n x n)
  • format - Format of the output matrix (“csr” or “coo”)

§Returns

A symmetric identity matrix

§Examples

use scirs2_sparse::construct_sym::eye_sym_array;

// Create a 3x3 symmetric identity matrix in CSR format
let eye = eye_sym_array::<f64>(3, "csr").unwrap();

assert_eq!(eye.shape(), (3, 3));
assert_eq!(eye.get(0, 0), 1.0);
assert_eq!(eye.get(1, 1), 1.0);
assert_eq!(eye.get(2, 2), 1.0);
assert_eq!(eye.get(0, 1), 0.0);