use ndarray::prelude::*;
use ndarray::*;
use num_complex::Complex;
#[allow(non_snake_case)]
#[inline(always)]
pub fn find_R<A: Data<Elem = T>, B: Data<Elem = T>, T: std::cmp::PartialEq>(
hamR: &ArrayBase<A, Ix2>,
R: &ArrayBase<B, Ix1>,
) -> Option<usize> {
let n_R: usize = hamR.len_of(Axis(0));
let dim_R: usize = hamR.len_of(Axis(1));
for i in 0..(n_R) {
let mut a = true;
for j in 0..(dim_R) {
a = a && (hamR[[i, j]] == R[[j]]);
}
if a {
return Some(i);
}
}
None
}
#[inline(always)]
pub fn remove_row<T: Copy>(array: Array2<T>, row_to_remove: usize) -> Array2<T> {
let indices: Vec<_> = (0..array.nrows()).filter(|&r| r != row_to_remove).collect();
array.select(Axis(0), &indices)
}
#[inline(always)]
pub fn remove_col<T: Copy>(array: Array2<T>, col_to_remove: usize) -> Array2<T> {
let indices: Vec<_> = (0..array.ncols()).filter(|&r| r != col_to_remove).collect();
array.select(Axis(1), &indices)
}