Home > tt2 > core > maxvol2.m

maxvol2

PURPOSE ^

Maximal volume submatrix in an tall matrix

SYNOPSIS ^

function [ind]=maxvol2(a,ind)

DESCRIPTION ^

Maximal volume submatrix in an tall matrix
   [IND]=MAXVOL2(A) computes maximal volume submatrix in n x r matrix A
   Returns rows indices that contain maximal volume submatrix



 TT-Toolbox 2.2, 2009-2012

This is TT Toolbox, written by Ivan Oseledets et al.
Institute of Numerical Mathematics, Moscow, Russia
webpage: http://spring.inm.ras.ru/osel

For all questions, bugs and suggestions please mail
ivan.oseledets@gmail.com
---------------------------

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ind]=maxvol2(a,ind)
0002 %Maximal volume submatrix in an tall matrix
0003 %   [IND]=MAXVOL2(A) computes maximal volume submatrix in n x r matrix A
0004 %   Returns rows indices that contain maximal volume submatrix
0005 %
0006 %
0007 %
0008 % TT-Toolbox 2.2, 2009-2012
0009 %
0010 %This is TT Toolbox, written by Ivan Oseledets et al.
0011 %Institute of Numerical Mathematics, Moscow, Russia
0012 %webpage: http://spring.inm.ras.ru/osel
0013 %
0014 %For all questions, bugs and suggestions please mail
0015 %ivan.oseledets@gmail.com
0016 %---------------------------
0017 n=size(a,1); r=size(a,2);
0018 if ( n <= r ) 
0019     ind = 1:n;
0020     return
0021 end
0022 
0023 %Initialize
0024 if ( nargin < 2 || isempty(ind) )
0025 [l_shit,u_shit,p]=lu(a,'vector');
0026 %p=randperm(n);
0027 ind=p(1:r);
0028 b=a(p,:);
0029 sbm=a(ind,:);
0030 z=b(r+1:n,:)/sbm; %Watch for this later on please
0031 end
0032 %Start iterations
0033 niters=100;
0034 eps=5e-2; %Stopping accuracy
0035 iter=0;
0036 while (iter <= niters);
0037 % [mx,pv]=max((abs(z))');
0038 [mx,pv]=max(abs(z), [], 2);
0039 [mx0,pv0]=max(mx);
0040 if ( mx0 <= 1 + eps ) 
0041     ind=sort(ind);
0042     return
0043     
0044 end 
0045 %Swap i0-th row with j0-th row
0046 i0=pv0;
0047 j0=pv(i0);
0048 i=p(i0+r);
0049 p(i0+r)=p(j0);
0050 p(j0)=i;
0051 bb=z(:,j0);
0052 bb(i0)=bb(i0)+1;
0053 cc=z(i0,:);
0054 cc(j0)=cc(j0)-1;
0055 z=z-bb*cc./z(i0,j0);
0056 iter=iter+1;
0057 ind=p(1:r);
0058 ind=sort(ind);
0059 end
0060 
0061 return
0062 end

Generated on Wed 08-Feb-2012 18:20:24 by m2html © 2005