Hi Alexandre,
I guess you want to just extract the diagonal of a square matrix? The following would work:
diag :: Elt e => Acc (Matrix e) -> Acc (Vector e)
diag mat =
generate -- https://hackage.haskell.org/package/accelerate-1.2.0.0/docs/Data-Array-Accelerate.html#v:generate
(indexTail (shape mat)) -- assume the matrix is square, then 'shape mat = Z :. n :. n'
(\ix -> let Z :. i = unlift ix -- at each index, read the diagonal element from 'mat'
in mat ! index2 i i)
If you want to go the other direction, you could do something like this.
Hope that helps!
-Trev
--
You received this message because you are subscribed to the Google Groups "Accelerate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelerate-hask...@googlegroups.com.
Visit this group at https://groups.google.com/group/accelerate-haskell.
For more options, visit https://groups.google.com/d/optout.