epic const generic array transpose
verified that this loop unrolls on compiler explorer
This commit is contained in:
parent
e95f675e91
commit
1a6ece1312
@ -20,6 +20,18 @@ macro_rules! impl_matrix {
|
||||
array:self.array.map(|inner|inner.map(&f)),
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn transpose(self)->Matrix<Y,X,T>{
|
||||
//how did I think of this
|
||||
let mut array_of_iterators=self.array.map(|axis|axis.into_iter());
|
||||
Matrix{
|
||||
array:core::array::from_fn(|_|
|
||||
array_of_iterators.each_mut().map(|iter|
|
||||
iter.next().unwrap()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<const X:usize,const Y:usize,T> Matrix<X,Y,T>
|
||||
where
|
||||
|
Loading…
Reference in New Issue
Block a user