Home > manopt > manifolds > ttfixedrank > TTeMPS_1.1 > algorithms > completion > makeOmegaSet.m

makeOmegaSet

PURPOSE ^

TTeMPS Toolbox.

SYNOPSIS ^

function subs = makeOmegaSet( n, sizeOmega )

DESCRIPTION ^

   TTeMPS Toolbox. 
   Michael Steinlechner, 2013-2016
   Questions and contact: michael.steinlechner@epfl.ch
   BSD 2-clause license, see LICENSE.txt

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %   TTeMPS Toolbox.
0002 %   Michael Steinlechner, 2013-2016
0003 %   Questions and contact: michael.steinlechner@epfl.ch
0004 %   BSD 2-clause license, see LICENSE.txt
0005 function subs = makeOmegaSet( n, sizeOmega )
0006     
0007     if sizeOmega > prod(n)
0008         error('makeOmegaSet:sizeOmegaTooHigh', 'Requested size of Omega is bigger than the tensor itself!')
0009     end
0010 
0011     idx = randi( prod(n), sizeOmega, 1 );
0012     Omega = unique(idx);
0013 
0014     while length(Omega) < sizeOmega
0015         idx = [ Omega; randi( prod(n) , sizeOmega-length(Omega), 1 )]; 
0016         Omega = unique(idx);
0017     end
0018     
0019     Omega = sort( Omega(1:sizeOmega) );
0020 
0021     % get number of dimensions
0022     d = length(n);
0023     % prepare dynamically sized varargout for ind2sub
0024     % (careful! needs to be done because behaviour of ind2sub depends
0025     % on the number of output arguments)
0026     c = cell(1,d);
0027     [c{:}] = ind2sub( n, Omega );
0028 
0029     subs = [c{:}];
0030 end

Generated on Fri 30-Sep-2022 13:18:25 by m2html © 2005