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 slparblocks
Home > sltoolbox > utils > slparblocks.m

slparblocks

PURPOSE ^

SLPARBLOCKS Gets the blocks from partition structure

SYNOPSIS ^

function blocks = slparblocks(ps)

DESCRIPTION ^

SLPARBLOCKS Gets the blocks from partition structure

 $ Syntax $
   - blocks = slparblocks(ps)

 $ Arguments $
   - ps:       the partition structure generated from slpartition
   - blocks:   the cell array of block ranges

 $ Description $
   - blocks = slparblocks(ps) gets the a cell array of blocks 
     corresponding to the partition structure. If there are d dimensions
     and m1, m2, ..., md partitions along each dimension. Then an
     m1 x m2 x ... x md cell array will be returned, with each cell
     containing a 2 x d array, in the form of 
     [s1, s2, ..., sd; e1, e2, ..., ed]. It means that the block of
     data will be extracted from an whole array A as
     A(s1:e1, s2:e2, ..., sd:ed).

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

CROSS-REFERENCE INFORMATION ^

This function calls:
  • slallsubinds SLALLSUBINDS Generate all sub-indices for all elements of the array
This function is called by:
  • slpwcomp_blks SLPWCOMP_BLKS Computes pairwise value matrix
  • slpartitionpca SLPARTITIONPCA Performs Partition-based PCA and saves the models

SOURCE CODE ^

0001 function blocks = slparblocks(ps)
0002 %SLPARBLOCKS Gets the blocks from partition structure
0003 %
0004 % $ Syntax $
0005 %   - blocks = slparblocks(ps)
0006 %
0007 % $ Arguments $
0008 %   - ps:       the partition structure generated from slpartition
0009 %   - blocks:   the cell array of block ranges
0010 %
0011 % $ Description $
0012 %   - blocks = slparblocks(ps) gets the a cell array of blocks
0013 %     corresponding to the partition structure. If there are d dimensions
0014 %     and m1, m2, ..., md partitions along each dimension. Then an
0015 %     m1 x m2 x ... x md cell array will be returned, with each cell
0016 %     containing a 2 x d array, in the form of
0017 %     [s1, s2, ..., sd; e1, e2, ..., ed]. It means that the block of
0018 %     data will be extracted from an whole array A as
0019 %     A(s1:e1, s2:e2, ..., sd:ed).
0020 %
0021 % $ History $
0022 %   - Created by Dahua Lin, on Jul 29th, 2006
0023 %
0024 
0025 
0026 % calculate block numbers
0027 
0028 d = length(ps);
0029 
0030 blknums = zeros(1, d);
0031 for i = 1 : d
0032     blknums(i) = length(ps(i).sinds);
0033 end
0034 
0035 % get block ranges
0036 
0037 blkinds = slallsubinds(blknums);
0038 NBlks = prod(blknums);
0039 blkinds = reshape(blkinds, [d, NBlks]);
0040 
0041 Smat = zeros(d, NBlks);
0042 Emat = zeros(d, NBlks);
0043 for i = 1 : d
0044     Smat(i, :) = ps(i).sinds(blkinds(i, 1:NBlks));
0045     Emat(i, :) = ps(i).einds(blkinds(i, 1:NBlks));
0046 end
0047 
0048 
0049 % convert from block range array to block cell array
0050 
0051 Smat = reshape(Smat, [1, d*NBlks]);
0052 Emat = reshape(Emat, [1, d*NBlks]);
0053 Bmat = [Smat; Emat];
0054 clear Smat Emat;
0055 
0056 tempd = zeros(1, NBlks);
0057 tempd(:) = d;
0058 blocks = mat2cell(Bmat, 2, tempd);
0059 
0060 if d == 1
0061     blocks = blocks(:);
0062 else
0063     blocks = reshape(blocks, blknums);
0064 end
0065 
0066 
0067 
0068 
0069

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

Contact us at files@mathworks.com