Code covered by the BSD License  

Highlights from
Statistical Learning Toolbox

from Statistical Learning Toolbox by Dahua Lin
Functions for statistical learning, pattern recognition and computer vision, covering many topics.

Description of slallsubinds
Home > sltoolbox > utils > slallsubinds.m

slallsubinds

PURPOSE ^

SLALLSUBINDS Generate all sub-indices for all elements of the array

SYNOPSIS ^

function S = slallsubinds(arrsiz)

DESCRIPTION ^

SLALLSUBINDS Generate all sub-indices for all elements of the array

 $ Syntax $
   - S = slallsubinds(arrsiz)
 
 $ Arguments $
   - arrsiz:       the size of the array
   - S:            the array of all sub indices

 $ Description $
   - S = slallsubinds(arrsiz) generates all sub-indices for all elements
     of the array. Suppose arrsiz is n1, n2, ..., nd. Then the output S
     would be a d x n1 x n2 x ... x nd array, with each d-length column
     corresponding to the sub-index of an element.

 $ History $
   - Created by Dahua Lin on Jul 29th, 2006

CROSS-REFERENCE INFORMATION ^

This function calls:
This function is called by:
  • slpartitionpca SLPARTITIONPCA Performs Partition-based PCA and saves the models
  • slparblocks SLPARBLOCKS Gets the blocks from partition structure

SOURCE CODE ^

0001 function S = slallsubinds(arrsiz)
0002 %SLALLSUBINDS Generate all sub-indices for all elements of the array
0003 %
0004 % $ Syntax $
0005 %   - S = slallsubinds(arrsiz)
0006 %
0007 % $ Arguments $
0008 %   - arrsiz:       the size of the array
0009 %   - S:            the array of all sub indices
0010 %
0011 % $ Description $
0012 %   - S = slallsubinds(arrsiz) generates all sub-indices for all elements
0013 %     of the array. Suppose arrsiz is n1, n2, ..., nd. Then the output S
0014 %     would be a d x n1 x n2 x ... x nd array, with each d-length column
0015 %     corresponding to the sub-index of an element.
0016 %
0017 % $ History $
0018 %   - Created by Dahua Lin on Jul 29th, 2006
0019 %
0020 
0021 
0022 arrsiz = arrsiz(:)';
0023 d = length(arrsiz);
0024 
0025 if d == 1
0026     S = (1:arrsiz)';
0027     
0028 else
0029     totalnum = prod(arrsiz);
0030     ms = cumprod([1, arrsiz(1:d-1)]);
0031     ns = totalnum ./ (arrsiz  .* ms);
0032     
0033     S = zeros(d, totalnum);
0034     for i = 1 : d
0035         
0036         M = 1 : arrsiz(i);
0037         M = M(ones(1, ms(i)), M, ones(1, ns(i)));
0038         
0039         S(i, :) = reshape(M, [1, totalnum]);        
0040     end
0041     
0042     S = reshape(S, [d, arrsiz]);    
0043 end
0044

Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003

Contact us at files@mathworks.com