MINTRACE find row permutation to minimize the trace p=(x) Inputs: x(n,n) is a square real-valued matrix Outputs: p(n,1) is the row permutation that minimizes the trace so that trace(x(p,:)) is as small as possible

- permutes PERMUTES All N! permutations of 1:N + signatures [P,S]=(N)

0001 function p=mintrace(x) 0002 %MINTRACE find row permutation to minimize the trace p=(x) 0003 %Inputs: x(n,n) is a square real-valued matrix 0004 % 0005 %Outputs: p(n,1) is the row permutation that minimizes the trace 0006 % so that trace(x(p,:)) is as small as possible 0007 0008 % Copyright (C) Mike Brookes 2012-2013 0009 % Version: $Id: mintrace.m 2718 2013-02-23 09:34:45Z dmb $ 0010 % 0011 % VOICEBOX is a MATLAB toolbox for speech processing. 0012 % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 0013 % 0014 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0015 % This program is free software; you can redistribute it and/or modify 0016 % it under the terms of the GNU General Public License as published by 0017 % the Free Software Foundation; either version 2 of the License, or 0018 % (at your option) any later version. 0019 % 0020 % This program is distributed in the hope that it will be useful, 0021 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0022 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0023 % GNU General Public License for more details. 0024 % 0025 % You can obtain a copy of the GNU General Public License from 0026 % http://www.gnu.org/copyleft/gpl.html or by writing to 0027 % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0029 n=size(x,1); % input x must be square 0030 p=permutes(n); % try all permutations 0031 c=0:n:n^2-1; % convert olumns to single indexing 0032 [v,i]=min(sum(x(p+c(ones(length(p),1),:)),2)); 0033 p=p(i,:)'; 0034

Generated on Wed 28-Mar-2018 15:33:24 by