alexmatm.sa
Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
-- Copyright (C) 1983 1992 1996 Kouji KODAMA
--
-- 1998/1
--LongInt
--
--1997/1
--Theta curve
--un-oriented surface in S^4
--
--1996/10
--LINUX version
--
--bug fix for 2-knot
--
--92/09/30 03:14:42
--1992/6 Alexander matrix and Alexander polynomial.
--1992/6/20: 10para99(parallel of k10c99. 40 crossing) 10sec.
--K. Kodama
class ALEXMATM
class ALEXMATM is
-- ALEXMATmaxC=maxC;
--matV=array[1..ALEXMATmaxC] OF PolyInt;
--pmatV=POINTER TO matV;
--amatV=array[1..ALEXMATmaxC] OF pmatV;
shared AMat:MAT_POLYM_INTI;
shared trimN:INT; -- number of deleted relation
shared trimC:INT; -- component of over bridge of deleted relation
shared jPivot:ARRAY{INT};
shared Relator:ARRAY{WORD};
shared g2c:ARRAY{INT};
shared compoN:INT; -- #of component
WriteMatrix(p0:INT) is
zFlg:BOOL;
LOGOUT::Title("Alexander","matrix");
zFlg:=true;
degR::=AMat.nr; degG::=AMat.nc;
--if p0>degR then p0:=degR; end;
--if p0>degG then p0:=degG; end;
-- Alexander matrix is the form of
--\pmatrix{
--diagonal & 0 \cr
-- 0 & matrix \cr
--}
if (degR=degG)and(p0=degR-1) then p0:=degR; end;
-- Write diagonal part.
d0:INT; -- length of diagonel part
d0:=(p0).min(degR).min(degG);
loop i::=1.upto!(trimN);
zFlg:=false;
#LOGOUT+"diagonal part: 0\n";
end;
loop i::=0.upto!(d0-1); j::=jPivot[i];
if (~AMat[i][j].is_one)and(~AMat[i][j].negate.is_one)
then
zFlg:=false;
#LOGOUT+"diagonal part: "+
AMat[i][j].str("tex")+"\n";
end;
end;
-- Write other part
if (p0<degR)or(p0<degG) then
#LOGOUT+"\pmatrix{\n";
loop i::=(p0).upto!(degR-1);
loop j::=(p0).upto!(degG-1); zFlg:=false;
if p0<j then #LOGOUT+" & "; end;
#LOGOUT+AMat[i][jPivot[j]].str("tex");
end;
#LOGOUT+" \\cr"+"\n";
end;
#LOGOUT+"}\n";
end;
if zFlg then #LOGOUT+"0\n"; end;
end;
MakeMatrix(TCode:TCODE) is
-- RLength
KNOT_GROUP::get_Relator(TCode, out Relator, out g2c);
--#OUT+"Rel:\n";
--loop i::=Relator.ind!; #OUT+Relator[i].str+"\n"; end;
trimN:=0; trimC:=0; compoN:=TCode[TCode.length].compo;
g:INT:=g2c.size-1;
r:INT:=Relator.size;
jPivot:=#(g); loop i::=jPivot.ind!; jPivot[i]:=i; end;
AMat:=#(r,g); AMat.clear;
if (r=0)or(g=0) then return; end;
loop i::=0.upto!(r-1);
-- Make relation with Fox's free differential
AMat[i][Relator[i][0]-1]:=
AMat[i][Relator[i][0]-1]
+(POLYM_INTI::one);
AMat[i][Relator[i][1]-1]:=
AMat[i][Relator[i][1]-1]
+(#POLYM_INTI("x"+g2c[Relator[i][0]].str));
if Relator[i].w.has_ind(2) then
AMat[i][-Relator[i][2]-1]:=
AMat[i][-Relator[i][2]-1]
-(#POLYM_INTI("x"+g2c[Relator[i][1]].str));
end;
if Relator[i].w.has_ind(3) then
AMat[i][-Relator[i][3]-1]:=
AMat[i][-Relator[i][3]-1]
-(POLYM_INTI::one);
end;
-- #OUT+"AMat:"+i.int+":"
-- +AMat[i][Relator[i][0]-1].str+", "
-- +AMat[i][Relator[i][1]-1].str+", "
-- +AMat[i][-Relator[i][2]-1].str+", "
-- +AMat[i][-Relator[i][3]-1].str+"\n";
end;
end;
trimMat1(TCode:TCODE) is
-- delete a crossing relation
delR,delG:INT;
pt:INT:=0; word:WORD;
trimN:=0;
if TCode.has_band then -- 2-dim knot/link
res::=KNOT_GROUP::getCrossR(TCode, inout pt, out word);
if res and (pt<TCode.bandStart) then
-- not implemented.
end;
else -- 1-dim knot/link
res::=KNOT_GROUP::getCrossR(TCode, inout pt, out word);
if res and (pt<TCode.bandStart) then
trimN:=1;
delR:=1; delG:=word[1];
trimC:=g2c[delG];
AMat:=AMat.minor_matrix(delR-1,delG-1);
jPivot:=#(AMat.nc); loop i::=jPivot.ind!; jPivot[i]:=i; end;
end;
end;
end;
AlexPoly(p0:INT, out apoly:POLYM_INTI) is
apoly:=POLYM_INTI::one; --- alex.poly
if AMat.nr/=AMat.nc then
#OUT+"Alexander matrix is not square.\n";
apoly:=POLYM_INTI::zero;
return;
end;
pw:POLYM_INTI; -- work
-- diagonal part
countz::=0; -- count "0"
loop i::=0.upto!(p0-1);
pw:=AMat[i,jPivot[i]];
if pw.is_zero then countz:=countz+1;
else
apoly:=apoly*pw;
end;
end;
-- non-diagonal part
if countz+trimN<=1 then
if p0<AMat.nr then
mat::=AMat.copy;
loop i::=0.upto!(p0-1);
mat:=mat.minor_matrix(0,jPivot[i]);
loop j::=i.upto!(jPivot.size-1);
if jPivot[j]>jPivot[i] then jPivot[j]:=jPivot[j]-1; end;
end;
end;
apoly:=apoly*mat.det;
end;
else apoly:=POLYM_INTI::zero;
end;
if apoly.is_zero.not then
apoly:=apoly/#POLYM_INTI(apoly.gcd_term);
-- if apoly.substitute(1.inti)<0.inti then apoly:=-apoly; end;
--printApoly(apoly);
if (trimN=1)and(compoN>1) then
apoly:=apoly/(#POLYM_INTI("x"+trimC.str)-1.inti);
end;
slist:MAP{STR,POLYM_INTI}:=#;
loop i::=1.upto!(compoN);
slist["x"+i.str]:=#POLYM_INTI(1.inti);
end;
res_p::=apoly.substitute(slist);
if res_p.lc<0.inti then apoly:=-apoly; end;
end;
end;
printApoly(apoly:POLYM_INTI) is
LOGOUT::Title("Alexander","Polynomial");
#LOGOUT+apoly.str("tex");
#LOGOUT+"\n";
end;
APolyOut(p0:INT) is
pa:POLYM_INTI;
AlexPoly(p0,out pa);
printApoly(pa);
end;
AlexMat(TCode:TCODE) is
rDeg:INT;
POLYM_INTI::init;
-- matrix
MakeMatrix(TCode);
-- print
#LOGOUT+"\n";
if AMat.nr<1 or AMat.nc<1 then
#LOGOUT+"The ";
if TCode[TCode.length].compo=1 then
#LOGOUT+"knot";
else
#LOGOUT+"link";
end;
if AMat.nc<1 then #LOGOUT+" is empty.";
else #LOGOUT+" is Trivial.";
end;
return;
else
LOGOUT::LogTime;
WriteMatrix(0);
trimMat1(TCode);
MAT_POLYM_INTI_REDUCTION::reduce(inout AMat,out jPivot,out rDeg);
-- WriteMatrix(0);
WriteMatrix(rDeg);
-- polynomial
if ~TCode.has_band then
APolyOut(rDeg);
end;
end;
#LOGOUT+"\n"; LOGOUT::flush;
end;
end;