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

slequalpar2D

PURPOSE ^

SLEQUALPAR Partition a 2D array with balances for width and height

SYNOPSIS ^

function ps = slequalpar2D(siz, maxblk)

DESCRIPTION ^

SLEQUALPAR Partition a 2D array with balances for width and height

 $ Syntax $
   - ps = slequalpar2D(siz, maxblk)

 $ Arguments $
   - siz:      The size of the 2D array to be partitioned
   - maxblk:   The maximum number of elements in each block
   - ps:       The partition structure

 $ Description $
   - ps = slequalpar2D(siz, maxblk) partitions the 2D array into blocks
     such that for each block the height and width should be as close
     as possible.

 $ History $
   - Created by Dahua Lin, on Sep 8th, 2006

CROSS-REFERENCE INFORMATION ^

This function calls:
  • slpartition SLPARTITION Partition a range into blocks in a specified manner
This function is called by:
  • slpwgraph SLVALGRAPH Constructs a graph by computing values between nodes pairwisely

SOURCE CODE ^

0001 function ps = slequalpar2D(siz, maxblk)
0002 %SLEQUALPAR Partition a 2D array with balances for width and height
0003 %
0004 % $ Syntax $
0005 %   - ps = slequalpar2D(siz, maxblk)
0006 %
0007 % $ Arguments $
0008 %   - siz:      The size of the 2D array to be partitioned
0009 %   - maxblk:   The maximum number of elements in each block
0010 %   - ps:       The partition structure
0011 %
0012 % $ Description $
0013 %   - ps = slequalpar2D(siz, maxblk) partitions the 2D array into blocks
0014 %     such that for each block the height and width should be as close
0015 %     as possible.
0016 %
0017 % $ History $
0018 %   - Created by Dahua Lin, on Sep 8th, 2006
0019 %
0020 
0021 m = siz(1);
0022 n = siz(2);
0023 ne = m * n;
0024 
0025 if ne <= maxblk    % not partitioned
0026     ps = struct('sinds', {1, 1}, 'einds', {m, n});
0027 else
0028     b = max(sqrt(maxblk), 1);
0029     if b <= m && b <= n
0030         bm = b;
0031         bn = b;
0032     elseif b > m
0033         bm = m;
0034         bn = maxblk / m;
0035     else
0036         bn = n;
0037         bm = maxblk / n;
0038     end
0039     nm = ceil(m / bm);
0040     nn = ceil(n / bn);    
0041     ps = slpartition(siz, 'numblks', [nm, nn]); 
0042 end
0043 
0044 
0045     
0046     
0047 
0048 
0049 
0050 
0051

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

Contact us at files@mathworks.com