У меня есть функция, которая выполняет следующий цикл много-много раз:
for cluster=1:max(bins), % bins is a list in the same format as kmeans() IDX output
select=bins==cluster; % find group of values
means(select,:)=repmat_fast_spec(meanOneIn(x(select,:)),sum(select),1);
% (*, above) for each point, write the mean of all points in x that
% share its label in bins to the equivalent row of means
delta_x(select,:)=x(select,:)-(means(select,:));
%subtract out the mean from each point
end
Отмечая, что repmat_fast_spec
и meanOneIn
являются урезанными версиями repmat()
и mean()
соответственно, мне интересно, есть ли способ выполнить присвоение в строке, помеченной (*), которая позволяет избежать повторения полностью.
Любые другие мысли о том, как выжать производительность из этой вещи, также приветствуются.