Home > matgraph > @partition > subsref.m

subsref

PURPOSE ^

subsref --- implements the notation p(v) and p(v,w)

SYNOPSIS ^

function vec = subsref(p,S)

DESCRIPTION ^

 subsref --- implements the notation p(v) and p(v,w)
 p(v) returns the part containing v
 p(v,w) returns 1 if v and w are in the same part and 0 otherwise

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function vec = subsref(p,S)
0002 % subsref --- implements the notation p(v) and p(v,w)
0003 % p(v) returns the part containing v
0004 % p(v,w) returns 1 if v and w are in the same part and 0 otherwise
0005 
0006 
0007 args = S.subs;
0008 [m,n] = size(p.array);
0009 
0010 % single subscript case
0011 
0012 if length(args)==1
0013     v = args(1);
0014     v = v{1};
0015     if (v<1) | (v>n)
0016         vec = [];
0017     else
0018         r = find(p.array(:,v));
0019         vec = find(p.array(r,:));
0020     end
0021     return
0022 end
0023 
0024 % two subscript case
0025 
0026 v = args(1);
0027 v = v{1};
0028 w = args(2);
0029 w = w{1};
0030 
0031 if (v<1) | (v>n) | (w<1) | (w>n) 
0032     vec = false;
0033     return
0034 end
0035 
0036 r1 = find(p.array(:,v));
0037 r2 = find(p.array(:,w));
0038 vec = r1==r2;

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