Unprotect[SquareMatrixQ];

<<KnotTheory`

(* The DT code for the K_G knot from the RBG link in Section 5 *)

(* First, some subsequences corresponding to the four strands going into the full twist #1 at the bottom of the figure *)

R1[a_, b_, c_, d_, e_, f_]:=If [ b > 0, Riffle[
Riffle[ -Range [2a+12b+2c+12d+2e+18, 2a+6b+2c+12d+2e+24,-6], Range[2a+18b+4c+18d+4e+4f+26,2a+12b+4c+18d+4e+4f+32 , -6]],
Range[2a+18b+4c+24d+4e+4f+34,2a+24b+4c+24d+4e+4f+28 ,6],  {3, 3*b, 3}], {}];
R2[a_, b_, c_, d_, e_, f_]:=If [ b > 0, Riffle[
Riffle[ Range [2a+24b+4c+24d+4e+4f+30,2a+18b+4c+24d+4e+4f+36 ,-6], -Range[6b+6d+6,6d+12 , -6]],
Range[2a+12b+4c+18d+4e+4f+34,2a+18b+4c+18d+4e+4f+28 ,6],  {3, 3*b, 3}], {}];
R3[a_, b_, c_, d_, e_, f_]:=If [ b > 0, Riffle[
Riffle[ Range [2a+6b+2c+12d+2e+20,2a+12b+2c+12d+2e+14 ,6], -Range[2a+24b+4c+24d+4e+4f+26,2a+18b+4c+24d+4e+4f+32 , -6]],
Range[6b+6d+2 ,6d+8,-6],  {3, 3*b, 3}], {}];
R4[a_, b_, c_, d_, e_, f_]:=If [ b > 0, Riffle[
Riffle[ Range [6d+10,6b+6d+4,6], Range[2a+12b+2c+12d+2e+16,2a+6b+2c+12d+2e+22,-6]],
-Range[2a+18b+4c+18d+4e+4f+24,2a+12b+4c+18d+4e+4f+30,-6],  {3, 3*b, 3}], {}];

(* Second, some subsequences corresponding to the four strands going into the full twist #3 in the middle of the figure *)
 Q1[a_, b_, c_, d_, e_, f_]:=If [ d > 0, Riffle[
Riffle[ Range [6b+2c+12d+2e+12 ,6b+2c+6d+2e+18,-6], -Range[2a+12b+2c+12d+2e+20,2a+12b+2c+18d+2e+14, 6]],
Range[2a+18b+4c+24d+4e+4f+26,2a+18b+4c+18d+4e+4f+32,-6],  {3, 3*d, 3}], {}];
Q2[a_, b_, c_, d_, e_, f_]:=If [ d > 0, Riffle[
Riffle[ Range [2a+12b+2c+18d+2e+16, 2a+12b+2c+12d+2e+22,-6], Range[6d+4,10, -6]],
-Range[2a+18b+4c+18d+4e+4f+36,2a+18b+4c+24d+4e+4f+30,6],  {3, 3*d, 3}], {}];
Q3[a_, b_, c_, d_, e_, f_]:=If [ d > 0, Riffle[
Riffle[ Range [6b+2c+12d+2e+10, 6b+2c+6d+2e+16,-6], Range[2a+18b+4c+24d+4e+4f+28,2a+18b+4c+18d+4e+4f+34, -6]],
-Range[12,6d+6,6],  {3, 3*d, 3}], {}];
Q4[a_, b_, c_, d_, e_, f_]:=If [ d > 0, Riffle[
Riffle[ Range [2a+12b+2c+18d+2e+18, 2a+12b+2c+12d+2e+24,-6], -Range[6b+2c+6d+2e+14,6b+2c+12d+2e+8, 6]],
Range[6d+2,8,-6],  {3, 3*d, 3}], {}];

(*Now, the DT code for the whole picture *)
g[a_, b_,c_,d_,e_, f_, alpha_, beta_, gamma_, delta_, epsilon_, phi_]:= Join[ {-(2a+12b+2c+18d+4e+2f+28), 2a+12b+2c+18d+4e+24, -(6b+2c+6d+10)}, delta*Q1[a,b,c, d, e, f], {2a+12b+2c+18d+2e+20},beta*R1[a,b,c,d,e,f],  gamma*Range[2a+12b+4c+18d+4e+4f+28,2a+12b+2c+18d+4e+4f+30, -2], {-4, 6b+2c+12d+2e+14}, epsilon*Range[2a+12b+2c+18d+4e+20, 2a+12b+2c+18d+2e+22, -2], delta*Q2[a, b, c, d,e ,f ], {-(2a+12b+2c+18d+4e+22), 6b+6d+2c+8, 2a+12b+2c+18d+4e+2f+26}, alpha*Range[4a+24b+4c+24d+4e+4f+30, 2a+24b+4c+24d+4e+4f+32,-2], beta*R2[a,b,c,d,e,f], delta*Q3[a,b,c,d,e,f], {-(2a+18b+4c+18d+4e+4f+30), -(6b+2c+6d+2e+12)}, epsilon*Range[6b+2c+6d+2e+10, 6b+2c+6d+12, -2],{6, -(6b+2c+12d+2e+16)}, phi*Range[ 2a+12b+2c+18d+4e+4f+28, 2a+12b+2c+18d+4e+2f+30, -2],{-2, 6b+2c+12d+2e+18}, phi*Range[2a+12b+2c+18d+4e+2f+24,2a+12b+2c+18d+4e+26, -2], gamma*Range[6b+6d+2c+6, 6b+6d+8, -2],  beta*R3[a, b, c, d, e, f], delta*Q4[a,b,c,d,e,f], beta*R4[a, b, c, d, e, f],alpha*Range[2a+6b+2c+12d+2e+18, 6b+2c+12d+2e+20, -2]];

KG[x_, y_, z_, u_, v_, w_] = -g[Abs[x], Abs[y], Abs[z], Abs[u], Abs[v], Abs[w], Sign[x], -Sign[y], -Sign[z], -Sign[u], -Sign[v], -Sign[w]];

(* The DT code for the K_B knot from the same RBG link *)

(* First, some subsequences corresponding to the four strands going into the full twist #1 at the bottom of the figure *)

RR1[a_, b_, c_, d_, e_, f_]:=If [ b > 0, Riffle[
Riffle[ Range [2a+6b+2e+6f+14,2a+12b+2e+6f+8 ,6], Range[4a+18b+2c+2e+12f+10,4a+12b+2c+2e+12f+16 , -6]],
-Range[4a+24b+4c+2e+18f+16, 4a+18b+4c+2e+18f+22,-6],  {3, 3*b, 3}], {}];
RR2[a_, b_, c_, d_, e_, f_]:=If [ b > 0, Riffle[
Riffle[ -Range [4a+18b+2c+2e+12f+12,4a+12b+2c+2e+12f+18 ,-6], Range[4a+24b+4c+2e+18f+18 ,4a+18b+4c+2e+18f+24, -6]],
Range[10, 6b+4 ,6],  {3, 3*b, 3}], {}];
RR3[a_, b_, c_, d_, e_, f_]:=If [ b > 0, Riffle[
Riffle[ Range [6b+6, 12,-6], -Range[2a+12b+2e+6f+10, 2a+6b+2e+6f+16 , -6]],
Range[4a+18b+4c+2e+18f+26, 4a+24b+4c+2e+18f+20,6],  {3, 3*b, 3}], {}];
RR4[a_, b_, c_, d_, e_, f_]:=If [ b > 0, Riffle[
Riffle[ Range [4a+12b+2c+2e+12f+14, 4a+18b+2c+2e+12f+8,6], -Range[6b+2,8,-6]],
Range[2a+12b+2e+6f+6, 2a+6b+2e+6f+12,-6],  {3, 3*b, 3}], {}];

(* Second, some subsequences corresponding to the four strands going into the full twist #5 on the right of the figure *)
 QQ1[a_, b_, c_, d_, e_, f_]:=If [ f > 0, Riffle[
Riffle[ Range [2a+12b+2c+2e+12f+12,2a+12b+2c+2e+6f+18,-6], -Range[4a+18b+2c+2e+12f+20, 4a+18b+2c+2e+18f+14, 6]],
Range[4a+24b+4c+4d+4e+24f+26,4a+24b+4c+4d+4e+18f+32,-6],  {3, 3*f, 3}], {}];
QQ2[a_, b_, c_, d_, e_, f_]:=If [ f> 0, Riffle[
Riffle[ Range [4a+18b+2c+2e+18f+16,4a+18b+2c+2e+12f+22 ,-6], Range[2a+6b+6f+4,2a+6b+10, -6]],
-Range[4a+24b+4c+4d+4e+18f+36, 4a+24b+4c+4d+4e+24f+30,6],  {3, 3*f, 3}], {}];
QQ3[a_, b_, c_, d_, e_, f_]:=If [ f > 0, Riffle[
Riffle[ Range [2a+12b+2c+2e+12f+10,2a+12b+2c+2e+6f+16,-6], Range[4a+24b+4c+4d+4e+24f+28,4a+24b+4c+4d+4e+18f+34,  -6]],
-Range[2a+6b+12,2a+6b+6f+6,6],  {3, 3*f, 3}], {}];
QQ4[a_, b_, c_, d_, e_, f_]:=If [ f > 0, Riffle[
Riffle[ Range [4a+18b+2c+2e+18f+18,4a+18b+2c+2e+12f+24 ,-6], -Range[2a+12b+2c+2e+6f+14, 2a+12b+2c+2e+12f+8, 6]],
Range[2a+6b+6f+2, 2a+6b+8,-6],  {3, 3*f, 3}], {}];

(*Now, the DT code for the whole picture *)
gg[a_, b_,c_,d_,e_, f_, alpha_, beta_, gamma_, delta_, epsilon_, phi_]:= Join[ {4a+24b+4c+4d+4e+18f+28, -(2a+6b+6f+10), 4a+24b+4c+2d+2e+18f+24}, beta*RR1[a,b,c, d, e, f],  alpha*Range[4a+12b+2c+2e+12f+12, 2a+12b+2c+2e+12f+14, -2], phi*QQ1[a,b,c,d,e,f], {-(4a+18b+2c+2e+18f+20), -2, 4a+18b+2c+2e+12f+16}, epsilon*Range[4a+24b+4c+4d+4e+18f+24, 4a+24b+4c+4d+2e+18f+26, -2], beta*RR2[a,b,c,d,e,f], gamma*Range[4a+18b+4c+2e+18f+20, 4a+18b+2c+2e+18f+22, -2], phi*QQ2[a,b,c,d,e,f], alpha*Range[2a+6b+6, 6b+8, -2], beta*RR3[a,b,c,d,e,f], {-(4a+24b+4c+2d+2e+18f+22), -(4a+24b+4c+4d+4e+18f+26), 2a+6b+6f+8},phi*QQ3[a,b,c,d,e,f], {4a+24b+4c+4d+4e+18f+30, (2a+12b+2c+2e+6f+12)}, gamma*Range[2a+12b+2c+2e+6f+10, 2a+12b+2e+6f+12, -2], beta*RR4[a,b,c,d,e,f], delta*Range[4a+24b+4c+4d+2e+18f+24, 4a+24b+4c+2d+2e+18f+26, -2], {6, - (4a+18b+2c+2e+12f+14)}, delta*Range[4a+24b+4c+2d+2e+18f+20, 4a+24b+4c+2e+18f+22, -2], epsilon*Range[2a+6b+2e+6f+10, 2a+6b+6f+12, -2], {4, -(4a+18b+2c+2e+12f+18)}, phi*QQ4[a,b,c,d,e,f]
];

KB[x_, y_, z_, u_, v_, w_] = -gg[Abs[x], Abs[y], Abs[z], Abs[u], Abs[v], Abs[w], Sign[x], -Sign[y], -Sign[z], -Sign[u], -Sign[v], -Sign[w]];

(* We can compute signatures and s invariants for families of KG and KB knots using routines as the following *)

Flatten[Table[sInvariant[PD[DTCode[KB7[i,j,k, l, m, n]/.List->Sequence]]], {i, 1, 1}, {j, 1,1}, {k, -2, -2}, {l, -1,1},{m, -2,2}, {n, -1, 1}]]

{2,2,2,2,2,0,2,0,0,0,0,0,0,0,0,2,2,0,2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0}