twobridge.sa
Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
class TWOBRIDGE_CNV
class TWOBRIDGE_CNV is
TwoBridge2Knot(str:STR,inout knot:KNOT):BOOL is
res:BOOL:=TwoBridge2NDataStr(inout str) and NDATA_CNV::NDataStr2Knot(str, inout knot);
if ~res then knot.NoCompo0; else knot.transform(0.int,-1,1.int,0.int); end;
return res;
end;
TwoBridge2NDataStr(b:ARRAY{INT},out str:STR):BOOL is
-- get n-data from Conway's notation.
str:="n1 n3";
loop i::=b.ind!; e::=b.elt!;
if e.is_non_zero then code:STR:="";
if i.is_odd then e:=-e; end; if e>0.int then code:="r"; else code:="l"; end;
if i.is_even then code:=code+"2"; else code:=code+"1"; end;
e:=e.abs; if e>1.int then code:=e.str+code; end;
str:=str+" "+code;
end;
end;
if b.size.is_odd then str:=str+" u3 u1 endcode"; else str:=str+" u2 u1 endcode"; end;
return true
end;
TwoBridge2NDataStr(inout s:STR):BOOL is
i::=s.search(":"); j::=s.search("endcode");
if ((0<i)and(i<j)).not then return false; end;
data_type::=s.head(i); s:=s.substring(i+1,j-i-1);
if data_type.has_ind(data_type.search("s")) then -- Schubert's notation S(p/q)
sc:STR_CURSOR:=#(s); if sc.is_done then return false; end;
p:INT:=#(STRINGSK::splitStr(inout sc)); if sc.is_done then return false; end;
q:INT:=#(STRINGSK::splitStr(inout sc));
ai::=RAT_EXT::continued_fraction(#(p,q));
a:ARRAY{INT}:=#(ai.size); loop a[0.up!]:=ai.elt!.int; end;
return TwoBridge2NDataStr(a,out s);
elsif data_type.search("c")>=0 then -- Conway's notation C(a0 a1 a2 ...)
return TwoBridge2NDataStr(#WORD(s).w,out s);
else return false;
end;
end;
end;