Home > FR3DSource > sFindPermutation.m

sFindPermutation

PURPOSE ^

xFindPermutation(b);

SYNOPSIS ^

function [Perm] = xFindPermutation(NNZ);

DESCRIPTION ^

  xFindPermutation(b);

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 %  xFindPermutation(b);
0002 
0003 function [Perm] = xFindPermutation(NNZ);
0004 
0005 [m,n] = size(NNZ);
0006 
0007 count = 0;
0008 for i=2:min(9,n)
0009   for j=1:(i-1)
0010     count=count+1;
0011     LEN(count,1)=NNZ(i,j);
0012     LEN(count,2:3)=[i,j];
0013   end
0014 end
0015 
0016 Loc=1;
0017 i=1:n;
0018 while Loc+1<n 
0019     [a,b]=sortrows(LEN,1);
0020     [LEN,i]=MakeMinFirst(LEN,b,i,Loc);
0021     Loc=Loc+2;
0022 end
0023 
0024 Perm=i;
0025 
0026 %---------------------------------------------------
0027 function [LEN,i]=MakeMinFirst(LEN,b,i,Loc)
0028 
0029 % switch first number
0030 k=find(i==LEN(b(1),2));
0031 t=i(Loc);
0032 i(Loc)=LEN(b(1),2); 
0033 i(k)=t;
0034 
0035 % switch 2nd number
0036 k=find(i==LEN(b(1),3));
0037 t=i(Loc+1);
0038 i(Loc+1)=LEN(b(1),3); 
0039 i(k)=t;
0040 
0041 c=find(LEN(:,2)~=LEN(b(1),3) & LEN(:,2)~=LEN(b(1),2) & LEN(:,3)~=LEN(b(1),3) & LEN(:,3)~=LEN(b(1),2));
0042 LEN=LEN(c,:);
0043 
0044 
0045 
0046 
0047

Generated on Fri 03-Apr-2009 09:52:35 by m2html © 2003