Faster way of writing this code: (finding index)
3 ビュー (過去 30 日間)
The code I want to optimize is:
index_min = sum( input > quantiles );
where quantiles is a vector of doubles in increasing order. I am using the sum function to find the index of quantiles that corresponds to the value of input. I think the "find" function is actually slower.
回答 (2 件)
Matt Fig 2012 年 12 月 22 日
That code does not return an index, but it does return the number of values in vector quantiles that are smaller than input.