tp@0: function [reftoshort,sho1,sho2,sho3,sho4,sho5,sho6,sho7,examplecombination] = ... tp@0: EDB1compress7(Big1,Big2,Big3,Big4,Big5,Big6,Big7) tp@0: % EDB1compress7 - tp@0: % This function looks for combinations of N edges-to-N edges that have identical tp@0: % values for 7 [N,N] matrices. The values are rounded to a relative tp@0: % accuracy of 1e-12. tp@0: % tp@0: % Input parameters: tp@0: % Big1, Big2,...,Big 7 Seven matrices, [N,N], of data. tp@0: % tp@0: % Output parameters: tp@0: % reftoshort Matrix, [N,N], of pointer values to seven short tp@0: % lists. tp@0: % sho1, sho2,...,sho7 Seven shortlists, [nshort,1], with values that tp@0: % are taken from the seven input matrices. tp@0: % examplecombination Vector of pointers from the short lists, back tp@0: % to the input matrices. tp@0: % tp@0: % Uses no special functions tp@0: % tp@0: % ---------------------------------------------------------------------------------------------- tp@0: % This file is part of the Edge Diffraction Toolbox by Peter Svensson. tp@0: % tp@0: % The Edge Diffraction Toolbox is free software: you can redistribute it and/or modify tp@0: % it under the terms of the GNU General Public License as published by the Free Software tp@0: % Foundation, either version 3 of the License, or (at your option) any later version. tp@0: % tp@0: % The Edge Diffraction Toolbox is distributed in the hope that it will be useful, tp@0: % but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS tp@0: % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. tp@0: % tp@0: % You should have received a copy of the GNU General Public License along with the tp@0: % Edge Diffraction Toolbox. If not, see . tp@0: % ---------------------------------------------------------------------------------------------- tp@0: % Peter Svensson (svensson@iet.ntnu.no) 20030503 tp@0: % tp@0: % [reftoshort,sho1,sho2,sho3,sho4,sho5,sho6,sho7,examplecombination] = ... tp@0: % EDB1compress7(Big1,Big2,Big3,Big4,Big5,Big6,Big7) tp@0: tp@0: accuracy = 1e-12; tp@0: tp@0: [n1,n2] = size(Big1); tp@0: tp@0: Big1 = reshape(Big1,n1*n2,1); tp@0: Big2 = reshape(Big2,n1*n2,1); tp@0: Big3 = reshape(Big3,n1*n2,1); tp@0: Big4 = reshape(Big4,n1*n2,1); tp@0: Big5 = reshape(Big5,n1*n2,1); tp@0: Big6 = reshape(Big6,n1*n2,1); tp@0: Big7 = reshape(Big7,n1*n2,1); tp@0: tp@0: maxamp = max(abs(Big1)); tp@0: if maxamp ~= 0 tp@0: Big1 = round( Big1/maxamp/accuracy)*accuracy*maxamp; tp@0: end tp@0: maxamp = max(abs(Big2)); tp@0: if maxamp ~= 0 tp@0: Big2 = round( Big2/maxamp/accuracy)*accuracy*maxamp; tp@0: end tp@0: maxamp = max(abs(Big3)); tp@0: if maxamp ~= 0 tp@0: Big3 = round( Big3/maxamp/accuracy)*accuracy*maxamp; tp@0: end tp@0: maxamp = max(abs(Big4)); tp@0: if maxamp ~= 0 tp@0: Big4 = round( Big4/maxamp/accuracy)*accuracy*maxamp; tp@0: end tp@0: maxamp = max(abs(Big5)); tp@0: if maxamp ~= 0 tp@0: Big5 = round( Big5/maxamp/accuracy)*accuracy*maxamp; tp@0: end tp@0: maxamp = max(abs(Big6)); tp@0: if maxamp ~= 0 tp@0: Big6 = round( Big6/maxamp/accuracy)*accuracy*maxamp; tp@0: end tp@0: maxamp = max(abs(Big7)); tp@0: if maxamp ~= 0 tp@0: Big7 = round( Big7/maxamp/accuracy)*accuracy*maxamp; tp@0: end tp@0: tp@0: %--------------------------------------- tp@0: % sort tp@0: tp@0: [Big1,sortvec] = sort(Big1); tp@0: Big2 = Big2(sortvec); tp@0: Big3 = Big3(sortvec); tp@0: Big4 = Big4(sortvec); tp@0: Big5 = Big5(sortvec); tp@0: Big6 = Big6(sortvec); tp@0: Big7 = Big7(sortvec); tp@0: tp@0: [Big2,sortvec2] = sort(Big2); tp@0: Big1 = Big1(sortvec2); tp@0: Big3 = Big3(sortvec2); tp@0: Big4 = Big4(sortvec2); tp@0: Big5 = Big5(sortvec2); tp@0: Big6 = Big6(sortvec2); tp@0: Big7 = Big7(sortvec2); tp@0: sortvec = sortvec(sortvec2); tp@0: tp@0: [Big3,sortvec2] = sort(Big3); tp@0: Big1 = Big1(sortvec2); tp@0: Big2 = Big2(sortvec2); tp@0: Big4 = Big4(sortvec2); tp@0: Big5 = Big5(sortvec2); tp@0: Big6 = Big6(sortvec2); tp@0: Big7 = Big7(sortvec2); tp@0: sortvec = sortvec(sortvec2); tp@0: tp@0: [Big4,sortvec2] = sort(Big4); tp@0: Big1 = Big1(sortvec2); tp@0: Big2 = Big2(sortvec2); tp@0: Big3 = Big3(sortvec2); tp@0: Big5 = Big5(sortvec2); tp@0: Big6 = Big6(sortvec2); tp@0: Big7 = Big7(sortvec2); tp@0: sortvec = sortvec(sortvec2); tp@0: tp@0: [Big5,sortvec2] = sort(Big5); tp@0: Big1 = Big1(sortvec2); tp@0: Big2 = Big2(sortvec2); tp@0: Big3 = Big3(sortvec2); tp@0: Big4 = Big4(sortvec2); tp@0: Big6 = Big6(sortvec2); tp@0: Big7 = Big7(sortvec2); tp@0: sortvec = sortvec(sortvec2); tp@0: tp@0: [Big6,sortvec2] = sort(Big6); tp@0: Big1 = Big1(sortvec2); tp@0: Big2 = Big2(sortvec2); tp@0: Big3 = Big3(sortvec2); tp@0: Big4 = Big4(sortvec2); tp@0: Big5 = Big5(sortvec2); tp@0: Big7 = Big7(sortvec2); tp@0: sortvec = sortvec(sortvec2); tp@0: tp@0: [Big7,sortvec2] = sort(Big7); tp@0: Big1 = Big1(sortvec2); tp@0: Big2 = Big2(sortvec2); tp@0: Big3 = Big3(sortvec2); tp@0: Big4 = Big4(sortvec2); tp@0: Big5 = Big5(sortvec2); tp@0: Big6 = Big6(sortvec2); tp@0: sortvec = sortvec(sortvec2); tp@0: tp@0: ivec1 = find( abs(diff(Big1)) > accuracy ); tp@0: ivec2 = find( abs(diff(Big2)) > accuracy ); tp@0: ivec3 = find( abs(diff(Big3)) > accuracy ); tp@0: ivec4 = find( abs(diff(Big4)) > accuracy ); tp@0: ivec5= find( abs(diff(Big5)) > accuracy ); tp@0: ivec6= find( abs(diff(Big6)) > accuracy ); tp@0: ivec7= find( abs(diff(Big7)) > accuracy ); tp@0: tp@0: ivec = [0;sort([ivec1;ivec2;ivec3;ivec4;ivec5;ivec6;ivec7])]; tp@0: tp@0: if length(ivec) > 1 tp@0: ivec = ivec( find(diff(ivec) ~= 0) + 1 ); tp@0: ivec = [1;ivec + 1;n1*n2+1]; tp@0: tp@0: sho1 = Big1( ivec(1:length(ivec)-1)); tp@0: sho2 = Big2( ivec(1:length(ivec)-1)); tp@0: sho3 = Big3( ivec(1:length(ivec)-1)); tp@0: sho4 = Big4( ivec(1:length(ivec)-1)); tp@0: sho5 = Big5( ivec(1:length(ivec)-1)); tp@0: sho6 = Big6( ivec(1:length(ivec)-1)); tp@0: sho7 = Big7( ivec(1:length(ivec)-1)); tp@0: tp@0: if length(ivec) < 256 tp@0: reftoshort = uint8(zeros( size(Big1) )); tp@0: elseif length(ivec) < 65536 tp@0: reftoshort = uint16(zeros( size(Big1) )); tp@0: else tp@0: reftoshort = uint32(zeros( size(Big1) )); tp@0: end tp@0: numberofoccurences = zeros( size(sho1) ); tp@0: examplecombination = zeros( size(sho1) ); tp@0: tp@0: for ii = 1:length(ivec)-1 tp@0: sameblock = sortvec( [ivec(ii):ivec(ii+1)-1] ); tp@0: reftoshort(sameblock) = ii*ones(size(sameblock)); tp@0: numberofoccurences(ii) = length( sameblock ); tp@0: examplecombination(ii) = sameblock(1); tp@0: patchcomb = sameblock(1); tp@0: end tp@0: tp@0: reftoshort = reshape(reftoshort,n1,n2); tp@0: tp@0: else % All IRs are the same tp@0: % The extra zero is added to give the right dimensions of the output tp@0: % vector when the shortlists are used. tp@0: tp@0: reftoshort = ones(n1,n2); tp@0: sho1 = [Big1(1,1);0]; tp@0: sho2 = [Big2(1,1);0]; tp@0: sho3 = [Big3(1,1);0]; tp@0: sho4 = [Big4(1,1);0]; tp@0: sho5 = [Big5(1,1);0]; tp@0: sho6 = [Big6(1,1);0]; tp@0: sho7 = [Big7(1,1);0]; tp@0: examplecombination = 1; tp@0: tp@0: end