Find the minima of the columns of a matrix along with their corresponding row indices with CUDA Thrust

Suppose to have a matrix and that you want to find the minima (or, of course, the maxima) of the columns of that matrix along with their corresponding row indices.
For example, if you have the following matrix:

[ 0 1 12 18 20 3 10 8 ]
[ 5 15 1 11 12 17 12 10 ]
[ 18 20 15 20 6 8 18 13 ]
[ 18 20 3 18 19 6 19 8 ]
[ 6 10 8 16 14 11 12 1 ]
[ 12 9 12 17 10 16 1 4 ]

you want the following output:

Min position = 0; Min value = 0
Min position = 0; Min value = 1
Min position = 1; Min value = 1
Min position = 1; Min value = 11
Min position = 2; Min value = 6
Min position = 0; Min value = 3

This is easy to achieve with CUDA Thrust and on our GitHub website you can find a fully worked example.

Leave a Reply

Your email address will not be published. Required fields are marked *