maxindex function

Get maxindex (length of boolean vector) and poslength (number of 'selected' elements)