allocation free dot product
dvc94ch opened this issue · comments
seems like a common operation. if Scale
had an as_mut
method maybe matmul
could be reused?
#[inline]
fn dot<T: Entity + SimpleEntity + ComplexField>(a: &Mat<T>, b: &Mat<T>) -> T {
// TODO: does this allocate?
(a.transpose() * b)[(0, 0)]
}
you can write a.as_ref().col(0).adjoint() * b.as_ref().col(0)
, which will give you a T
without allocating
though i should make it so you can just write a.col(0)
without the intermediate .as_ref()
thanks!