Home > matgraph > @partition > array.m

array

PURPOSE ^

array(p) --- return a single array showing the part numbers of elements.

SYNOPSIS ^

function a = array(p)

DESCRIPTION ^

 array(p) --- return a single array showing the part numbers of elements.
 If p is the partition { {1,2,4} {3,5,6} {7,8,9,10} } then array(p) gives 
 the array [1 1 2 1 2 2 3 3 3 3].

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function a = array(p)
0002 % array(p) --- return a single array showing the part numbers of elements.
0003 % If p is the partition { {1,2,4} {3,5,6} {7,8,9,10} } then array(p) gives
0004 % the array [1 1 2 1 2 2 3 3 3 3].
0005 
0006 n = nv(p);
0007 a = zeros(1,n);
0008 
0009 c = parts(p);
0010 for k=1:length(c)
0011     a(c{k}) = k;
0012 end

Generated on Thu 13-Mar-2008 14:23:52 by m2html © 2003