



CORE_HISTXT Core computational routine for HISTXT. C = CORE_HISTXT(X,D), where X is an M x N matrix, returns a D x N matrix C such that C(i,j) = #[X(:,j)=i]. CONDITIONS ---------- X must only contain integer values between 1 and D. X must be of type double.


0001 function C = CORE_histxt(X,d) 0002 %CORE_HISTXT Core computational routine for HISTXT. 0003 % C = CORE_HISTXT(X,D), where X is an M x N matrix, returns a D x N 0004 % matrix C such that C(i,j) = #[X(:,j)=i]. 0005 % 0006 % CONDITIONS 0007 % ---------- 0008 % X must only contain integer values between 1 and D. 0009 % X must be of type double. 0010 0011 C = hist(X,1:d); 0012 0013 0014 return; 0015 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% TEST CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0017 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0018 % data = ceil(256*rand(1e5,10)); 0019 % tic; counts = CORE_histxt(data,256); t(1) = toc; 0020 % tic; counts2 = hist(data,1:256); t(2) = toc; 0021 % printf('\nCORE_histxt took %5.3f sec and equivalent native code took %5.3f sec.', t(1), t(2)); 0022 % if (~isequal(counts,counts2)) 0023 % printf('The two calls did not produce the same results.'); 0024 % end