I am looking for a way to find the index corresponding to the maximum of each column. My goal is to avoid loops and find a Matlabic solution using the vectorized armadillo functions.
This is easy to do in Matlab with the following command: [~, maxIndices] = max (A);
In armadillo, you have a member function: A.max (row_of_max_val, col_of_max_val); which give the location of the maximum in the entire matrix.
And autonomous function vec M = max (A); which displays the maximum values โโof each column, but not their indices.
But none of them does the trick.
With columns, maximum indices can be used to write numerous algorithms in a more vectorial way. For example, it can be used in Viterbi decoding or in k-type clustering.
Obviously, this question can be generalized with minima instead of maxima and rows instead of columns.
Does anyone think of an alternative solution?
Best.
source share