(* ::Package:: *)

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

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


(* ::Input::Initialization:: *)
(*L should be a list of an odd number of odd integers.*)
OddPretzel[L_]:=Module[{s=Total[Abs/@L],x},
PD@@Flatten@Table[x = Sum[Abs[L[[j]]],{j,1,u-1}];

If[EvenQ[u],
If[L[[u]]>0,
Join[Table[X[s+x+Abs[L[[u]]]-2k,x+2+2k,s+x+Abs[L[[u]]]-2k-1,x+1+2k],{k,0,(Abs[L[[u]]]-1)/2}],
Table[X[x+2k,s+x+Abs[L[[u]]]+2-2k,x+1+2k,s+x+Abs[L[[u]]]+1-2k],{k,1,(Abs[L[[u]]]-1)/2}]],
Join[Table[X[x+1+2k,s+x+Abs[L[[u]]]-2k,x+2+2k,s+x+Abs[L[[u]]]+1-2k],{k,0,(Abs[L[[u]]]-1)/2}],
Table[X[s+x+Abs[L[[u]]]+1-2k,x+2k,s+x+Abs[L[[u]]]+2-2k,x+1+2k],{k,1,(Abs[L[[u]]]-1)/2}]]]
,
If[L[[u]]>0,
Join[Table[X[x+1+2k,s+x+Abs[L[[u]]]+1-2k,x+2+2k,s+x+Abs[L[[u]]]-2k],{k,0,(Abs[L[[u]]]-1)/2}],
Table[X[s+x+Abs[L[[u]]]+1-2k,x+1+2k,s+x+Abs[L[[u]]]+2-2k,x+2k],{k,1,(Abs[L[[u]]]-1)/2}]],
Join[Table[X[s+x+Abs[L[[u]]]-2k,x+1+2k,s+x+Abs[L[[u]]]+1-2k,x+2+2k],{k,0,(Abs[L[[u]]]-1)/2}],
Table[X[x+2k,s+x+Abs[L[[u]]]+1-2k,x+1+2k,s+x+Abs[L[[u]]]+2-2k],{k,1,(Abs[L[[u]]]-1)/2}]]]
]
,{u,Length[L]}]
]


(* ::Input::Initialization:: *)
(*L should be a list L={L0,L1,..,Ln} where L0 and n>=0 are even and the Li, i>0 are odd integers.*)
EOddPretzel[LL_]:=Module[{L=Rest@LL,s,x,y,n},
s=2Abs[LL[[1]]]+Total[Abs/@L];n=Length[L];
PD@@Flatten@
Join[
If[LL[[1]]>0,
Join[Table[X[1+2k,s+1-2k,2+2k,s-2k],{k,0,Abs[LL[[1]]]/2-1}],Table[X[s+1-2k,1+2k,s+2-2k,2k],{k,1,Abs[LL[[1]]]/2}]],
Join[Table[X[s-2k,1+2k,s+1-2k,2+2k],{k,0,Abs[LL[[1]]]/2-1}],Table[X[2k,s+1-2k,1+2k,s+2-2k],{k,1,Abs[LL[[1]]]/2}]]
],
Table[x = Sum[Abs[L[[j]]],{j,u+1,n}];y= Abs[LL[[1]]]+Sum[Abs[L[[j]]],{j,1,u-1}];

If[EvenQ[u],
If[L[[u]]>0,
Join[Table[X[s+x+1+2k,y+1+2k,s+x+2+2k,y+2+2k],{k,0,(Abs[L[[u]]]-1)/2}],
Table[X[y+2k,s+x+2k,y+1+2k,s+x+1+2k],{k,1,(Abs[L[[u]]]-1)/2}]],
Join[Table[X[y+1+2k,s+x+2+2k,y+2+2k,s+x+1+2k],{k,0,(Abs[L[[u]]]-1)/2}],
Table[X[s+x+2k,y+1+2k,s+x+1+2k,y+2k],{k,1,(Abs[L[[u]]]-1)/2}]]]
,
If[L[[u]]>0,
Join[Table[X[y+1+2k,s+x+1+2k,y+2+2k,s+x+2+2k],{k,0,(Abs[L[[u]]]-1)/2}],
Table[X[s+x+2k,y+2k,s+x+1+2k,y+1+2k],{k,1,(Abs[L[[u]]]-1)/2}]],
Join[Table[X[s+x+1+2k,y+2+2k,s+x+2+2k,y+1+2k],{k,0,(Abs[L[[u]]]-1)/2}],
Table[X[y+2k,s+x+1+2k,y+1+2k,s+x+2k],{k,1,(Abs[L[[u]]]-1)/2}]]]
]
,{u,Length[L]}]
]
]



