annotate private/EDB1compress7.m @ 18:2d5f50205527 jabuilder_int tip

Escape the trailing backslash as well
author Chris Cannam
date Tue, 30 Sep 2014 16:23:00 +0100
parents 90220f7249fc
children
rev   line source
tp@0 1 function [reftoshort,sho1,sho2,sho3,sho4,sho5,sho6,sho7,examplecombination] = ...
tp@0 2 EDB1compress7(Big1,Big2,Big3,Big4,Big5,Big6,Big7)
tp@0 3 % EDB1compress7 -
tp@0 4 % This function looks for combinations of N edges-to-N edges that have identical
tp@0 5 % values for 7 [N,N] matrices. The values are rounded to a relative
tp@0 6 % accuracy of 1e-12.
tp@0 7 %
tp@0 8 % Input parameters:
tp@0 9 % Big1, Big2,...,Big 7 Seven matrices, [N,N], of data.
tp@0 10 %
tp@0 11 % Output parameters:
tp@0 12 % reftoshort Matrix, [N,N], of pointer values to seven short
tp@0 13 % lists.
tp@0 14 % sho1, sho2,...,sho7 Seven shortlists, [nshort,1], with values that
tp@0 15 % are taken from the seven input matrices.
tp@0 16 % examplecombination Vector of pointers from the short lists, back
tp@0 17 % to the input matrices.
tp@0 18 %
tp@0 19 % Uses no special functions
tp@0 20 %
tp@0 21 % ----------------------------------------------------------------------------------------------
tp@0 22 % This file is part of the Edge Diffraction Toolbox by Peter Svensson.
tp@0 23 %
tp@0 24 % The Edge Diffraction Toolbox is free software: you can redistribute it and/or modify
tp@0 25 % it under the terms of the GNU General Public License as published by the Free Software
tp@0 26 % Foundation, either version 3 of the License, or (at your option) any later version.
tp@0 27 %
tp@0 28 % The Edge Diffraction Toolbox is distributed in the hope that it will be useful,
tp@0 29 % but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
tp@0 30 % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
tp@0 31 %
tp@0 32 % You should have received a copy of the GNU General Public License along with the
tp@0 33 % Edge Diffraction Toolbox. If not, see <http://www.gnu.org/licenses/>.
tp@0 34 % ----------------------------------------------------------------------------------------------
tp@0 35 % Peter Svensson (svensson@iet.ntnu.no) 20030503
tp@0 36 %
tp@0 37 % [reftoshort,sho1,sho2,sho3,sho4,sho5,sho6,sho7,examplecombination] = ...
tp@0 38 % EDB1compress7(Big1,Big2,Big3,Big4,Big5,Big6,Big7)
tp@0 39
tp@0 40 accuracy = 1e-12;
tp@0 41
tp@0 42 [n1,n2] = size(Big1);
tp@0 43
tp@0 44 Big1 = reshape(Big1,n1*n2,1);
tp@0 45 Big2 = reshape(Big2,n1*n2,1);
tp@0 46 Big3 = reshape(Big3,n1*n2,1);
tp@0 47 Big4 = reshape(Big4,n1*n2,1);
tp@0 48 Big5 = reshape(Big5,n1*n2,1);
tp@0 49 Big6 = reshape(Big6,n1*n2,1);
tp@0 50 Big7 = reshape(Big7,n1*n2,1);
tp@0 51
tp@0 52 maxamp = max(abs(Big1));
tp@0 53 if maxamp ~= 0
tp@0 54 Big1 = round( Big1/maxamp/accuracy)*accuracy*maxamp;
tp@0 55 end
tp@0 56 maxamp = max(abs(Big2));
tp@0 57 if maxamp ~= 0
tp@0 58 Big2 = round( Big2/maxamp/accuracy)*accuracy*maxamp;
tp@0 59 end
tp@0 60 maxamp = max(abs(Big3));
tp@0 61 if maxamp ~= 0
tp@0 62 Big3 = round( Big3/maxamp/accuracy)*accuracy*maxamp;
tp@0 63 end
tp@0 64 maxamp = max(abs(Big4));
tp@0 65 if maxamp ~= 0
tp@0 66 Big4 = round( Big4/maxamp/accuracy)*accuracy*maxamp;
tp@0 67 end
tp@0 68 maxamp = max(abs(Big5));
tp@0 69 if maxamp ~= 0
tp@0 70 Big5 = round( Big5/maxamp/accuracy)*accuracy*maxamp;
tp@0 71 end
tp@0 72 maxamp = max(abs(Big6));
tp@0 73 if maxamp ~= 0
tp@0 74 Big6 = round( Big6/maxamp/accuracy)*accuracy*maxamp;
tp@0 75 end
tp@0 76 maxamp = max(abs(Big7));
tp@0 77 if maxamp ~= 0
tp@0 78 Big7 = round( Big7/maxamp/accuracy)*accuracy*maxamp;
tp@0 79 end
tp@0 80
tp@0 81 %---------------------------------------
tp@0 82 % sort
tp@0 83
tp@0 84 [Big1,sortvec] = sort(Big1);
tp@0 85 Big2 = Big2(sortvec);
tp@0 86 Big3 = Big3(sortvec);
tp@0 87 Big4 = Big4(sortvec);
tp@0 88 Big5 = Big5(sortvec);
tp@0 89 Big6 = Big6(sortvec);
tp@0 90 Big7 = Big7(sortvec);
tp@0 91
tp@0 92 [Big2,sortvec2] = sort(Big2);
tp@0 93 Big1 = Big1(sortvec2);
tp@0 94 Big3 = Big3(sortvec2);
tp@0 95 Big4 = Big4(sortvec2);
tp@0 96 Big5 = Big5(sortvec2);
tp@0 97 Big6 = Big6(sortvec2);
tp@0 98 Big7 = Big7(sortvec2);
tp@0 99 sortvec = sortvec(sortvec2);
tp@0 100
tp@0 101 [Big3,sortvec2] = sort(Big3);
tp@0 102 Big1 = Big1(sortvec2);
tp@0 103 Big2 = Big2(sortvec2);
tp@0 104 Big4 = Big4(sortvec2);
tp@0 105 Big5 = Big5(sortvec2);
tp@0 106 Big6 = Big6(sortvec2);
tp@0 107 Big7 = Big7(sortvec2);
tp@0 108 sortvec = sortvec(sortvec2);
tp@0 109
tp@0 110 [Big4,sortvec2] = sort(Big4);
tp@0 111 Big1 = Big1(sortvec2);
tp@0 112 Big2 = Big2(sortvec2);
tp@0 113 Big3 = Big3(sortvec2);
tp@0 114 Big5 = Big5(sortvec2);
tp@0 115 Big6 = Big6(sortvec2);
tp@0 116 Big7 = Big7(sortvec2);
tp@0 117 sortvec = sortvec(sortvec2);
tp@0 118
tp@0 119 [Big5,sortvec2] = sort(Big5);
tp@0 120 Big1 = Big1(sortvec2);
tp@0 121 Big2 = Big2(sortvec2);
tp@0 122 Big3 = Big3(sortvec2);
tp@0 123 Big4 = Big4(sortvec2);
tp@0 124 Big6 = Big6(sortvec2);
tp@0 125 Big7 = Big7(sortvec2);
tp@0 126 sortvec = sortvec(sortvec2);
tp@0 127
tp@0 128 [Big6,sortvec2] = sort(Big6);
tp@0 129 Big1 = Big1(sortvec2);
tp@0 130 Big2 = Big2(sortvec2);
tp@0 131 Big3 = Big3(sortvec2);
tp@0 132 Big4 = Big4(sortvec2);
tp@0 133 Big5 = Big5(sortvec2);
tp@0 134 Big7 = Big7(sortvec2);
tp@0 135 sortvec = sortvec(sortvec2);
tp@0 136
tp@0 137 [Big7,sortvec2] = sort(Big7);
tp@0 138 Big1 = Big1(sortvec2);
tp@0 139 Big2 = Big2(sortvec2);
tp@0 140 Big3 = Big3(sortvec2);
tp@0 141 Big4 = Big4(sortvec2);
tp@0 142 Big5 = Big5(sortvec2);
tp@0 143 Big6 = Big6(sortvec2);
tp@0 144 sortvec = sortvec(sortvec2);
tp@0 145
tp@0 146 ivec1 = find( abs(diff(Big1)) > accuracy );
tp@0 147 ivec2 = find( abs(diff(Big2)) > accuracy );
tp@0 148 ivec3 = find( abs(diff(Big3)) > accuracy );
tp@0 149 ivec4 = find( abs(diff(Big4)) > accuracy );
tp@0 150 ivec5= find( abs(diff(Big5)) > accuracy );
tp@0 151 ivec6= find( abs(diff(Big6)) > accuracy );
tp@0 152 ivec7= find( abs(diff(Big7)) > accuracy );
tp@0 153
tp@0 154 ivec = [0;sort([ivec1;ivec2;ivec3;ivec4;ivec5;ivec6;ivec7])];
tp@0 155
tp@0 156 if length(ivec) > 1
tp@0 157 ivec = ivec( find(diff(ivec) ~= 0) + 1 );
tp@0 158 ivec = [1;ivec + 1;n1*n2+1];
tp@0 159
tp@0 160 sho1 = Big1( ivec(1:length(ivec)-1));
tp@0 161 sho2 = Big2( ivec(1:length(ivec)-1));
tp@0 162 sho3 = Big3( ivec(1:length(ivec)-1));
tp@0 163 sho4 = Big4( ivec(1:length(ivec)-1));
tp@0 164 sho5 = Big5( ivec(1:length(ivec)-1));
tp@0 165 sho6 = Big6( ivec(1:length(ivec)-1));
tp@0 166 sho7 = Big7( ivec(1:length(ivec)-1));
tp@0 167
tp@0 168 if length(ivec) < 256
tp@0 169 reftoshort = uint8(zeros( size(Big1) ));
tp@0 170 elseif length(ivec) < 65536
tp@0 171 reftoshort = uint16(zeros( size(Big1) ));
tp@0 172 else
tp@0 173 reftoshort = uint32(zeros( size(Big1) ));
tp@0 174 end
tp@0 175 numberofoccurences = zeros( size(sho1) );
tp@0 176 examplecombination = zeros( size(sho1) );
tp@0 177
tp@0 178 for ii = 1:length(ivec)-1
tp@0 179 sameblock = sortvec( [ivec(ii):ivec(ii+1)-1] );
tp@0 180 reftoshort(sameblock) = ii*ones(size(sameblock));
tp@0 181 numberofoccurences(ii) = length( sameblock );
tp@0 182 examplecombination(ii) = sameblock(1);
tp@0 183 patchcomb = sameblock(1);
tp@0 184 end
tp@0 185
tp@0 186 reftoshort = reshape(reftoshort,n1,n2);
tp@0 187
tp@0 188 else % All IRs are the same
tp@0 189 % The extra zero is added to give the right dimensions of the output
tp@0 190 % vector when the shortlists are used.
tp@0 191
tp@0 192 reftoshort = ones(n1,n2);
tp@0 193 sho1 = [Big1(1,1);0];
tp@0 194 sho2 = [Big2(1,1);0];
tp@0 195 sho3 = [Big3(1,1);0];
tp@0 196 sho4 = [Big4(1,1);0];
tp@0 197 sho5 = [Big5(1,1);0];
tp@0 198 sho6 = [Big6(1,1);0];
tp@0 199 sho7 = [Big7(1,1);0];
tp@0 200 examplecombination = 1;
tp@0 201
tp@0 202 end