(* ::Package:: *)

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
(* typically will have the same name as this file except ending in      *)
(* ".nb" instead of ".m".                                               *)
(*                                                                      *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs.  Doing so is equivalent   *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end.                                                                 *)
(*                                                                      *)
(* DO NOT EDIT THIS FILE.  This entire file is regenerated              *)
(* automatically each time the parent Notebook file is saved in the     *)
(* Mathematica front end.  Any changes you make to this file will be    *)
(* overwritten.                                                         *)
(************************************************************************)



(* ::Input::Initialization:: *)
SetDirectory["C:\\drorbn\\AcademicPensieve\\Projects\\Signatures"];
<< Common.m


(* ::Input::Initialization:: *)
TLS1[K_,\[Omega]_]:=Module[{spd,a,s=0,c,cs,A,is},
spd=Times@@PD[K]/.x_X:>If[PositiveQ@x,Xp,Xm]@@x;
cs=spd/.{
Xp[i_,j_,k_,l_]:>Subscript[a, j,i][++s]Subscript[a, k,-j][++s]Subscript[a, -l,-k][++s]Subscript[a, -i,l][++s],Xm[i_,j_,k_,l_]:>Subscript[a, -j,i][++s]Subscript[a, k,j][++s]Subscript[a, l,-k][++s]Subscript[a, -i,-l][++s]
}//.Subscript[a, i_,j_][x__]Subscript[a, j_,k_][y__]:>Subscript[a, i,k][x,y]/.Subscript[a, __][x__]:>a[x];
A=Table[0,Length@cs,Length@cs];
Do[is=Position[cs,4i-#][[1,1]]&/@{3,2,1,0};
A[[is,is]]+=If[spd[[i,0]]===Xp,\!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{"0", "0", "0", "0"},
{"1", 
RowBox[{"-", "1"}], "0", "0"},
{"0", 
RowBox[{"-", "1"}], "0", "1"},
{
RowBox[{"-", "1"}], "2", "0", 
RowBox[{"-", "1"}]}
},
GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}},
GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.7]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.4]}, Offset[0.2]}}], "", ")"}],
Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\),\!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{"1", 
RowBox[{"-", "1"}], "0", "0"},
{"0", "0", "0", "0"},
{
RowBox[{"-", "2"}], "1", "1", "0"},
{"1", "0", 
RowBox[{"-", "1"}], "0"}
},
GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}},
GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.7]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.4]}, Offset[0.2]}}], "", ")"}],
Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\)],
{i,Length[spd]} ];
Total[Sign[Select[
Eigenvalues[(1-\[Omega])A+(1-\[Omega]\[Conjugate])A\[Transpose]],Abs[#]>10^-6&]]] ];


(* ::Input::Initialization:: *)
TLS2[K_,\[Omega]_]:=Module[{spd,a,s=0,c,cs,A,is},
spd=Times@@PD[K]/.x_X:>If[PositiveQ@x,Xp,Xm]@@x;
cs=spd/.{
Xp[i_,j_,k_,l_]:>Subscript[a, j,i][++s]Subscript[a, k,-j][++s]Subscript[a, -l,-k][++s]Subscript[a, -i,l][++s],Xm[i_,j_,k_,l_]:>Subscript[a, -j,i][++s]Subscript[a, k,j][++s]Subscript[a, l,-k][++s]Subscript[a, -i,-l][++s]
}//.Subscript[a, i_,j_][x__]Subscript[a, j_,k_][y__]:>Subscript[a, i,k][x,y]/.Subscript[a, __][x__]:>a[x];
A=Table[0,Length@cs,Length@cs];
Do[is=Position[cs,4i-#][[1,1]]&/@{3,2,1,0};
A[[is,is]]+=If[spd[[i,0]]===Xp,
\!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{"0", 
RowBox[{"1", "-", 
RowBox[{"\[Omega]", "\[Conjugate]"}]}], "0", 
RowBox[{
RowBox[{"-", "1"}], "+", 
RowBox[{"\[Omega]", "\[Conjugate]"}]}]},
{
RowBox[{"1", "-", "\[Omega]"}], 
RowBox[{
RowBox[{"-", "2"}], "+", "\[Omega]", "+", 
RowBox[{"\[Omega]", "\[Conjugate]"}]}], 
RowBox[{
RowBox[{"-", "1"}], "+", 
RowBox[{"\[Omega]", "\[Conjugate]"}]}], 
RowBox[{"2", " ", 
RowBox[{"(", 
RowBox[{"1", "-", 
RowBox[{"\[Omega]", "\[Conjugate]"}]}], ")"}]}]},
{"0", 
RowBox[{
RowBox[{"-", "1"}], "+", "\[Omega]"}], "0", 
RowBox[{"1", "-", "\[Omega]"}]},
{
RowBox[{
RowBox[{"-", "1"}], "+", "\[Omega]"}], 
RowBox[{"2", " ", 
RowBox[{"(", 
RowBox[{"1", "-", "\[Omega]"}], ")"}]}], 
RowBox[{"1", "-", 
RowBox[{"\[Omega]", "\[Conjugate]"}]}], 
RowBox[{
RowBox[{"-", "2"}], "+", "\[Omega]", "+", 
RowBox[{"\[Omega]", "\[Conjugate]"}]}]}
},
GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}},
GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.7]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.4]}, Offset[0.2]}}], "", ")"}],
Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\),\!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{
RowBox[{"2", "-", "\[Omega]", "-", 
RowBox[{"\[Omega]", "\[Conjugate]"}]}], 
RowBox[{
RowBox[{"-", "1"}], "+", "\[Omega]"}], 
RowBox[{
RowBox[{"-", "2"}], " ", 
RowBox[{"(", 
RowBox[{"1", "-", 
RowBox[{"\[Omega]", "\[Conjugate]"}]}], ")"}]}], 
RowBox[{"1", "-", 
RowBox[{"\[Omega]", "\[Conjugate]"}]}]},
{
RowBox[{
RowBox[{"-", "1"}], "+", 
RowBox[{"\[Omega]", "\[Conjugate]"}]}], "0", 
RowBox[{"1", "-", 
RowBox[{"\[Omega]", "\[Conjugate]"}]}], "0"},
{
RowBox[{
RowBox[{"-", "2"}], " ", 
RowBox[{"(", 
RowBox[{"1", "-", "\[Omega]"}], ")"}]}], 
RowBox[{"1", "-", "\[Omega]"}], 
RowBox[{"2", "-", "\[Omega]", "-", 
RowBox[{"\[Omega]", "\[Conjugate]"}]}], 
RowBox[{
RowBox[{"-", "1"}], "+", 
RowBox[{"\[Omega]", "\[Conjugate]"}]}]},
{
RowBox[{"1", "-", "\[Omega]"}], "0", 
RowBox[{
RowBox[{"-", "1"}], "+", "\[Omega]"}], "0"}
},
GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}},
GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.7]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.4]}, Offset[0.2]}}], "", ")"}],
Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\)
],
{i,Length[spd]} ];
Total[Sign[Select[Eigenvalues[A],Abs[#]>10^-6&]]]
];


(* ::Input::Initialization:: *)
KC[K_,x1_,x2_]:=Module[{spd,a,s=0,c,cs,A,is,w=0},
spd=Times@@PD[K]/.x_X:>If[PositiveQ@x,Xp,Xm]@@x;
cs=spd/.{
Xp[i_,j_,k_,l_]:>Subscript[a, j,i][++s]Subscript[a, k,-j][++s]Subscript[a, -l,-k][++s]Subscript[a, -i,l][++s],Xm[i_,j_,k_,l_]:>Subscript[a, -j,i][++s]Subscript[a, k,j][++s]Subscript[a, l,-k][++s]Subscript[a, -i,-l][++s]
}//.Subscript[a, i_,j_][x__]Subscript[a, j_,k_][y__]:>Subscript[a, i,k][x,y]/.Subscript[a, __][x__]:>a[x];
A=Table[0,Length@cs,Length@cs];
Do[is=Position[cs,4i-#][[1,1]]&/@{3,2,1,0};
A[[is,is]]+=If[spd[[i,0]]===Xp,
\!\(
TagBox[
RowBox[{
RowBox[{"++", "w"}], ";", 
RowBox[{"(", GridBox[{
{"1", "x1", "1", "x1"},
{"x1", 
RowBox[{"x2", " "}], "x1", "1"},
{"1", "x1", "1", "x1"},
{"x1", "1", "x1", "x2"}
},
GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}},
GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.7]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.4]}, Offset[0.2]}}], ")"}]}],
Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\),--w;\!\(\*
TagBox[
RowBox[{"(", GridBox[{
{
RowBox[{"-", "x2"}], 
RowBox[{"-", "x1"}], 
RowBox[{"-", "1"}], 
RowBox[{"-", "x1"}]},
{
RowBox[{"-", "x1"}], 
RowBox[{"-", "1"}], 
RowBox[{"-", "x1"}], 
RowBox[{"-", "1"}]},
{
RowBox[{"-", "1"}], 
RowBox[{"-", "x1"}], 
RowBox[{"-", "x2"}], 
RowBox[{"-", "x1"}]},
{
RowBox[{"-", "x1"}], 
RowBox[{"-", "1"}], 
RowBox[{"-", "x1"}], 
RowBox[{"-", "1"}]}
},
GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}},
GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.7]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.4]}, Offset[0.2]}}], ")"}],
Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\)
],
{i,Length[spd]} ];
(Total[Sign[Select[Eigenvalues[A],Abs[#]>10^-6&]]]-w)/2
];


(* ::Input::Initialization:: *)
KC2[K_,x1_,x2_]:=Module[{spd,a,s=0,c,cs,A,is,w=0},
spd=Times@@PD[K]/.x_X:>If[PositiveQ@x,Xp,Xm]@@x;
cs=spd/.{
Xp[i_,j_,k_,l_]:>Subscript[a, j,i][++s]Subscript[a, k,-j][++s]Subscript[a, -l,-k][++s]Subscript[a, -i,l][++s],Xm[i_,j_,k_,l_]:>Subscript[a, -j,i][++s]Subscript[a, k,j][++s]Subscript[a, l,-k][++s]Subscript[a, -i,-l][++s]
}//.Subscript[a, i_,j_][x__]Subscript[a, j_,k_][y__]:>Subscript[a, i,k][x,y]/.Subscript[a, __][x__]:>a[x];
A=Table[0,Length@cs,Length@cs];
Do[is=Position[cs,4i-#][[1,1]]&/@{3,2,1,0};
A[[is,is]]+=If[spd[[i,0]]===Xp,
\!\(
TagBox[
RowBox[{
RowBox[{"++", "w"}], ";", 
RowBox[{"(", GridBox[{
{"1", "x1", "1", "x1"},
{"x1", 
RowBox[{"x2", " "}], "x1", "1"},
{"1", "x1", "1", "x1"},
{"x1", "1", "x1", "x2"}
},
GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}},
GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.7]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.4]}, Offset[0.2]}}], ")"}]}],
Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\)-\!\(\*
TagBox[
RowBox[{"(", "", GridBox[{
{"1", "0", "0", "0"},
{"0", "1", "0", "0"},
{"0", "0", "1", "0"},
{"0", "0", "0", "1"}
},
GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}},
GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.7]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.4]}, Offset[0.2]}}], "", ")"}],
Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\),--w;\!\(\*
TagBox[
RowBox[{
RowBox[{"(", GridBox[{
{
RowBox[{"-", "x2"}], 
RowBox[{"-", "x1"}], 
RowBox[{"-", "1"}], 
RowBox[{"-", "x1"}]},
{
RowBox[{"-", "x1"}], 
RowBox[{"-", "1"}], 
RowBox[{"-", "x1"}], 
RowBox[{"-", "1"}]},
{
RowBox[{"-", "1"}], 
RowBox[{"-", "x1"}], 
RowBox[{"-", "x2"}], 
RowBox[{"-", "x1"}]},
{
RowBox[{"-", "x1"}], 
RowBox[{"-", "1"}], 
RowBox[{"-", "x1"}], 
RowBox[{"-", "1"}]}
},
GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}},
GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.7]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.4]}, Offset[0.2]}}], ")"}], "+", 
TagBox[
RowBox[{"(", "", GridBox[{
{"1", "0", "0", "0"},
{"0", "1", "0", "0"},
{"0", "0", "1", "0"},
{"0", "0", "0", "1"}
},
GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}},
GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.7]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.4]}, Offset[0.2]}}], "", ")"}],
Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]}],
Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\)
],
{i,Length[spd]} ];
(Total[Sign[Select[Eigenvalues[A],Abs[#]>10^-6&]]])/2
];



