



CORE_HISTXY Core computational routine for HISTXY.
Z = CORE_HISTXY(C,R,CMAX,RMAX) returns an RMAX x CMAX matrix Z such
that Z(i,j) = #[R(a)=i,C(b)=j].
CONDITIONS
----------
R and C must be column vectors of the same length.
R and C must only contain integer values between 1 and RMAX or CMAX
respectively.
R and C must be of type DOUBLE.
RMAX and CMAX must be integer-valued and of type DOUBLE.

0001 function Z = CORE_histxy(c,r,cmax,rmax) 0002 %CORE_HISTXY Core computational routine for HISTXY. 0003 % Z = CORE_HISTXY(C,R,CMAX,RMAX) returns an RMAX x CMAX matrix Z such 0004 % that Z(i,j) = #[R(a)=i,C(b)=j]. 0005 % 0006 % CONDITIONS 0007 % ---------- 0008 % R and C must be column vectors of the same length. 0009 % R and C must only contain integer values between 1 and RMAX or CMAX 0010 % respectively. 0011 % R and C must be of type DOUBLE. 0012 % RMAX and CMAX must be integer-valued and of type DOUBLE. 0013 0014 Z = full(sparse(r,c,1,rmax,cmax)); 0015 0016 0017 return; 0018 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% TEST CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0021 % rows = ceil(256*rand(1e6,1)); cols = ceil(128*rand(1e6,1)); 0022 % tic; counts = CORE_histxy(cols,rows,128,256); t(1) = toc; 0023 % tic; counts2 = full(sparse(rows,cols,1,256,128)); t(2) = toc; 0024 % printf('CORE_histxy took %5.3f sec and equivalent native code took %5.3f sec.', t(1), t(2)); 0025 % if (~isequal(counts,counts2)) 0026 % printf('The two calls did not produce the same results.'); 0027 % end