covering_dist.sa


Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
 
-- 1998/05/17
--CovD-Lk
--link support for CovD-Y 
--
--1998/05/08
--CovD-Br
--
--1998/05/07
--LongInt for H1b & H1u
--
--1998/04/25 K.Kodama
--CovD-H1
--
--1998/04/22 K.Kodama
--CovD-Yang 1-st version


class CD_YANG_COUNT

class CD_YANG_COUNT is attr ylist:ARRAY{ARRAY{CARD}}; -- ylist=ARRAY{ARRAY{CARD}}; [1..YangmaxC] OF permutation attr count:INTI; create:SAME is res:SAME:=new; res.count:=0.inti; res.ylist:=#; return res; end; create(yn:INT):SAME is res:SAME:=new; res.count:=0.inti; res.ylist:=#(yn.card); loop i::=res.ylist.ind!; res.ylist[i]:=#; end; return res; end; YangCompare(py1,py2:ARRAY{CARD}):INT is loop i::=1.up!; if i>REP::rcode.stack.Jn then return 0.int; elsif (py1[i]=0) then if (py2[i]=0) then return 0.int; else return -1; end; elsif (py2[i]=0) then return 1.int; elsif (py1[i]>py2[i]) then return 1.int; elsif (py1[i]<py2[i]) then return -1; end; end; end; compare(yl2:SAME):INT is c:INT; loop g::=ylist.ind!; c:=YangCompare(ylist[g], yl2.ylist[g]); if c.is_non_zero then return c; end; end; return 0.int; end; YangLt(y1,y2:ARRAY{CARD}):BOOL is return YangCompare(y1,y2)=1.int; end; sort is ylist.insertion_sort_by(bind(YangLt(_,_))); end; str:STR is res:STR:="("; s1::=""; loop r::=ylist.elt!; res:=res+s1; s1:=","; s2:STR:=""; loop i::=1.up!; while!((i<=REP::rcode.stack.Jn.card)and(r[i]/=0)); res:=res+s2+r[i].str; s2:="."; end; end; res:=res+";"+count.str+")"; return res; end; end;

class COVERING_DIST_YANG

class COVERING_DIST_YANG is -- Covering Distribution for Yang diagram -- attr cdY_tbl:ARRAY{CD_YANG_COUNT}; WriteCDYangLog is #LOGOUT+"\n"+"Covering Distribution of Yang diagram.\n" +"CovD-Yang(K,"+REP::rcode.stack.Jn.str+")= "; loop #LOGOUT+(cdY_tbl.elt!.str); end; #LOGOUT+"\n\n"; LOGOUT::flush; end; create:SAME is res:SAME:=new; res.cdY_tbl:=#; return res; end; addNewCell(yl:CD_YANG_COUNT) is n0::=cdY_tbl.size; cdY_tbl:=cdY_tbl.resize(n0+1); yl.count:=1.inti; cdY_tbl[n0]:=yl; end; IncCDYang is c:INT; yList1:CD_YANG_COUNT:=#; -- get Yang diagrams and sort loop y::=REP::rcode.YangList.elt!; yList1.ylist:=yList1.ylist.append(REP::rcode.stack.st[y].copy); end; yList1.sort; -- search entry loop i::=cdY_tbl.ind!; if yList1.compare(cdY_tbl[i]).is_zero then cdY_tbl[i].count:=cdY_tbl[i].count+1.inti; return; end; end; addNewCell(yList1); end; end; -- class COVERING_DIST_YANG is

class CD_BR_COUNT

class CD_BR_COUNT is attr brlist:ARRAY{ARRAY{CARD}}; -- list of branch index attr count:INTI; create:SAME is res:SAME:=new; res.count:=0.inti; res.brlist:=#; return res; end; BrCompare(b1,b2:ARRAY{CARD}):INT is loop i::=0.up!; if b1.has_ind(i) and b2.has_ind(i) then if b1[i]>b2[i] then return 1.int; end; if b1[i]<b2[i] then return -1; end; elsif b1.has_ind(i) then return 1.int; elsif b2.has_ind(i) then return -1; else return 0.int; end; end; end; compare(bl2:SAME):INT is c:INT; loop g::=brlist.ind!; c:=BrCompare(brlist[g],bl2.brlist[g]); if c.is_non_zero then return c; end; end; return 0.int; end; BrLt(b1,b2:ARRAY{CARD}):BOOL is return BrCompare(b1,b2)=1.int; end; sort is brlist.insertion_sort_by(bind(BrLt(_,_))); end; str:STR is res:STR:="("; s1:STR:=""; loop br::=brlist.elt!; res:=res+s1; s1:=","; s2:STR:=""; loop i::=br.elt!; res:=res+s2+i.str; s2:="."; end; end; res:=res+";"+count.str+")"; return res; end; end;

class COVERING_DIST_BR

class COVERING_DIST_BR is -- Covering Distribution for BranchIndex attr CDBr:ARRAY{CD_BR_COUNT}; WriteCDBranchindexLog is #LOGOUT+"\nCovering Distribution of Branch index.\n" +"CovD-Br(K,"+REP::rcode.stack.Jn.str+")= "; loop #LOGOUT+(CDBr.elt!.str); end; #LOGOUT+"\n\n"; LOGOUT::flush; end; create:SAME is res:SAME:=new; res.CDBr:=#; return res; end; addNewCell(bl:CD_BR_COUNT) is n0::=CDBr.size; CDBr:=CDBr.resize(n0+1); bl.count:=1.inti; CDBr[n0]:=bl; end; IncCDBranchindex(brindex:ARRAY{ARRAY{CARD}}) is c:INT; bl:CD_BR_COUNT:=#; bl.brlist:=brindex; bl.sort; -- #OUT+"IncCDBranchindex:"+ bl.str+"\n"; loop i::=CDBr.ind!; c:=bl.compare(CDBr[i]); if c.is_zero then CDBr[i].count:=CDBr[i].count+1.inti; return; end; end; addNewCell(bl); end; end; -- class COVERING_DIST_BR

class CD_LK_COUNT

class CD_LK_COUNT is attr lklist:ARRAY{RAT}; attr count:INTI; create:SAME is res:SAME:=new; res.count:=0.inti; res.lklist:=#; return res; end; str:STR is res:STR:="("; if lklist.size >0 then s:STR:=""; loop i::=lklist.ind!; res:=res+s+lklist[i].str; s:=","; end; else res:=res+"x"; end; res:=res+";"+count.str+")"; return res; end; compare(lk2:SAME):INT is loop i::=0.up!; if lklist.has_ind(i) and lk2.lklist.has_ind(i) then if lklist[i]>lk2.lklist[i] then return 1; end; if lklist[i]<lk2.lklist[i] then return -1; end; elsif lklist.has_ind(i) then return 1; elsif lk2.lklist.has_ind(i) then return -1; else return 0; end; end; end; sort is lklist.sort; end; end;

class COVERING_DIST_LK

class COVERING_DIST_LK is -- Covering Distribution for Covering Linkage attr CDLk:ARRAY{CD_LK_COUNT}; WriteCDLinkingLog is #LOGOUT+"\nCovering Distribution of Covering linkage.\n" +"CovD-Lk(K,"+REP::rcode.stack.Jn.str+")= "; loop #LOGOUT+(CDLk.elt!.str); end; #LOGOUT+"\n\n"; LOGOUT::flush; end; create:SAME is res:SAME:=new; res.CDLk:=#; return res; end; addNewCell( lk:CD_LK_COUNT) is n0::=CDLk.size; CDLk:=CDLk.resize(n0+1); lk.count:=1.inti; CDLk[n0]:=lk; end; IncCDLinking(link:MAT_RAT, NOrbit:CARD) is lk:CD_LK_COUNT:=#; loop i::=1.upto!(NOrbit); loop j::=(i+1).upto!(NOrbit); if (link[i][0]/=#RAT(-1)) then lk.lklist:=lk.lklist.append(link[i][j]); elsif (link[j][0]/=#RAT(-1)) then lk.lklist:=lk.lklist.append(link[j][i]); else lk.lklist:=lk.lklist.append(#RAT(0)); end; end; end; lk.sort; c:INT; loop i::=CDLk.ind!; c:=lk.compare(CDLk[i]); if c.is_zero then CDLk[i].count:=CDLk[i].count+1.inti; return; end; end; addNewCell(lk); end; end; -- class COVERING_DIST_LK

class CD_H1_COUNT

class CD_H1_COUNT is attr group:ARRAY{INTI}; attr count:INTI; create:SAME is res:SAME:=new; res.count:=0.inti; res.group:=#; return res; end; str:STR is res:STR:="("; s:STR:=""; if group.size=0 then res:=res+"1"; else loop i::=group.ind!; res:=res+s+group[i].str; s:=","; end; end; res:=res+";"+count.str+")"; return res; end; compare(g1:SAME):INT is c:INTI; loop i::=0.up!; if group.has_ind(i) and g1.group.has_ind(i) then c:=group[i]-g1.group[i]; if c>0.inti then return 1; end; if c<0.inti then return -1; end; elsif group.has_ind(i) then return 1; elsif g1.group.has_ind(i) then return -1; else return 0 end; end; end; sort is group.sort; end; end;

class COVERING_DIST_H1

class COVERING_DIST_H1 is -- Covering Distribution for H1. attr CDH1:ARRAY{CD_H1_COUNT}; WriteCDH1Log(m:STR) is -- "u" or "b" m1:STR; if m="b" then m1:="br"; elsif m="u" then m1:="unbr"; else return; end; #LOGOUT+"\n"+"Covering Distribution of H1("+m1+".cover).\n" +"CovD-H1"+m+"(K,"+REP::rcode.stack.Jn.str+")= "; loop #LOGOUT+(CDH1.elt!.str); end; #LOGOUT+"\n\n"; LOGOUT::flush; end; create:SAME is res:SAME:=new; res.CDH1:=#; return res; end; addNewCell(h1c:CD_H1_COUNT) is n0::=CDH1.size; CDH1:=CDH1.resize(n0+1); h1c.count:=1.inti; CDH1[n0]:=h1c; end; IncCDH1(Group:ARRAY{INTI}) is CDH1w:CD_H1_COUNT:=#; CDH1w.group:=Group.copy; CDH1w.sort; -- search entry c:INT; loop i::=CDH1.ind!; c:=CDH1w.compare(CDH1[i]); if c.is_zero then CDH1[i].count:=CDH1[i].count+1.inti; return; end; end; addNewCell(CDH1w); end; end; -- class COVERING_DIST_H1 is