У меня есть (уродливое, но эффективное) решение для этой проблемы, которое я использовал недавно:
import java.lang.reflect.TypeVariable;
public static <T> Class<T> getGenericClass()
{
__<T> ins = new __<T>();
TypeVariable<?>[] cls = ins.getClass().getTypeParameters();
return (Class<T>)cls[0].getClass();
}
private final class __<T> // generic helper class which does only provide type information
{
private __()
{
}
}
Вам нужно будет установить некоторый допуск к min
. Скажем, `a 'является одним из ваших массивов:
tol = 0.001; % set this to proper value
minV = min(a); % find min
ind = find(a < minV+tol); % indices smaller than minV+tol
Вы можете установить tol
на процент от minV
, если это имеет смысл.