(* Define lines, as vectors in I^{6,1} *)
line=Table[0,{i,27},{j,7}];

s=1

For[i=1,i≤6,i++, line[[s,i]]=1;s++]

For[i=1,i≤6,i++, 
line[[s,7]]=2;
For[k=1,k≤6,k++, If[k≠i,line[[s,k]]=-1]];
s++
]

For[i=1,i≤6,i++, 
For[j=i+1,j≤6,j++,
line[[s,7]]=1; line[[s,i]]=-1; line[[s,j]]=-1; s++]]

(* line//MatrixForm *)

(* Define roots, as vectors in I^{6,1} *)
root=Table[0,{i,36},{j,7}];

r=1;

For[i=1,i≤6,i++, 
For[j=i+1,j≤6,j++,
root[[r,i]]=1;root[[r,j]]=-1; r++]]

For[i=1,i≤6,i++, 
For[j=i+1,j≤6,j++,
For[k=j+1,k≤6,k++,
root[[r,7]]=1;root[[r,i]]=-1;root[[r,j]]=-1; root[[r,k]]=-1;r++]]]

root[[36,7]]=2; For[i=1,i≤6,i++, root[[36,i]]=-1]

(* root//MatrixForm *)

(* Lorenzian dot product in I^{1,6} *)

mdot[x_,y_]:=x[[7]]*y[[7]]-x[[1]]*y[[1]]-x[[2]]*y[[2]]-x[[3]]*y[[3]]-x[[4]]*y[[4]]-x[[5]]*y[[5]]-x[[6]]*y[[6]]

(* Prods=Table[0,{i,36},{j,27}]; *)

(* For[n=1,n≤36,n++, 
For[m=1,m≤27,m++,
 Prods[[n,m]]=mdot[ root[[n]],line[[m]] ] ]] *)

(* Prods//MatrixForm *)

twroot=Table[0,{i,12},{j,7}] ;(* 12 roots of E6, the first 6 roots chosen to form a basis *)

twroot[[1]]=root[[21]];
twroot[[2]]=root[[1]];
twroot[[3]]=root[[6]];
twroot[[4]]=root[[10]];
twroot[[5]]=root[[13]];
twroot[[6]]=root[[15]];

(* Next 6 roots *)

twroot[[7]]=root[[36]];
twroot[[8]]=root[[17]];
twroot[[9]]=root[[26]];
twroot[[10]]=root[[11]];
twroot[[11]]=root[[2]];
twroot[[12]]=root[[12]];

For[i=1,i≤12,i++, Print[twroot[[i]]] ]

mh=Table[0, {s,27}, {e,72}]; (* matrix computing H_1(Gamma,k) = H^0(C, k), s=sheet, e=edge *)
e=0; (* will increase e 6 times for each of the roots *)
newline=Table[0,{k,7}]; (* will be used to identify a reflected line *)For[i=1,i≤12,i++, (* 12 ramification points, 12 twroots *)
For[s=1,s≤27,s++,
If[ mdot[twroot[[i]],line[[s]]]==1,
{e++;
mh[[s,e]]=1;
(* now find the reflected line line[[s]]+twroot[[i]] *)  
newline=line[[s]]+twroot[[i]] ;
(* find the opposite line and modify mh accordingly *)
For[s2=1,s2≤27,s2++,
If[newline==line[[s2]], mh[[s2,e]]=-1,"" ];
]
}, ""
]
]
]
mh//MatrixForm
Print["h^0(C,K)=",MatrixRank[NullSpace[mh]]]

For[i=1,i≤12,i++,  q[i]=i]; (* set the 12 points *)
m1=Table[0, {s,54}, {e,72}]; (* matrix computing 1st copy of H^0(C, K-L), s=sheet, e=edge *)
e=0; (* will increase e 6 times for each of the roots *)
newline=Table[0,{k,7}]; (* will be used to identify a reflected line *)For[i=1,i≤12,i++, (* 12 ramification points, 12 twroots *)
For[s=1,s≤27,s++,
If[ mdot[twroot[[i]],line[[s]]]==1,
{e++;
m1[[s,e]]=1;m1[[27+s,e]]=q[i];
(* now find the reflected line line[[s]]+twroot[[i]] *)  
newline=line[[s]]+twroot[[i]] ;
(* find the opposite line and modify mh accordingly *)
For[s2=1,s2≤27,s2++,
If[newline==line[[s2]], {m1[[s2,e]]=-1; m1[[27+s2,e]]=-q[i]},"" ];
]
}, ""
]
]
]
m1//MatrixForm
Print["First copy of h^0(C-L,K)=",MatrixRank[NullSpace[m1]]]

For[i=1,i≤12,i++,  q[i]=i]; (* set the 12 points *)
m2=Table[0, {s,54}, {e,72}]; (* matrix computing 2nd copy of H^0(C, K-L), s=sheet, e=edge *)
e=0; (* will increase e 6 times for each of the roots *)
newline=Table[0,{k,7}]; (* will be used to identify a reflected line *)For[i=1,i≤12,i++, (* 12 ramification points, 12 twroots *)
For[s=1,s≤27,s++,
If[ mdot[twroot[[i]],line[[s]]]==1,
{e++;
m2[[s,e]]=1;m2[[27+s,e]]=1/q[i];
(* now find the reflected line line[[s]]+twroot[[i]] *)  
newline=line[[s]]+twroot[[i]] ;
(* find the opposite line and modify mh accordingly *)
For[s2=1,s2≤27,s2++,
If[newline==line[[s2]], {m2[[s2,e]]=-1; m2[[27+s2,e]]=-1/q[i]},"" ];
]
}, ""
]
]
]
m2//MatrixForm
Print["Second copy of h^0(C-L,K)=",MatrixRank[NullSpace[m2]]]

For[i=1,i≤12,i++,  q[i]=i]; (* set the 12 points *)
m5=Table[0, {s,27+12*5}, {e,72}]; (* matrix computing H^0(C,K)^{-5} *)
e=0; (* will increase e 6 times for each of the roots *)
newline=Table[0,{k,7}]; (* will be used to identify a reflected line *)For[i=1,i≤12,i++, (* 12 ramification points, 12 twroots *)
For[s=1,s≤27,s++,
If[ mdot[twroot[[i]],line[[s]]]==1,
{e++;
m5[[s,e]]=1;
(* now find the reflected line line[[s]]+twroot[[i]] *)  
newline=line[[s]]+twroot[[i]] ;
(* find the opposite line and modify mh accordingly *)
For[s2=1,s2≤27,s2++,
If[newline==line[[s2]], m5[[s2,e]]=-1;,"" ];
]
}, ""
]
]
]
(* so far we computed H^0(C,K) *)
(* now add the equations for H^0(C,K)^{-5} *)
k=0; s=27;
For[i=1,i≤12,i++,
For[j=1,j≤5,j++,
s++;
k++;
m5[[s,k]]=1; m5[[s,k+1]]=-1;
]
k++
]

m5//MatrixForm
Print["Dim of h^0(C-L,K)^{(-5)}=",MatrixRank[NullSpace[m5]]]

mtotal=Join[NullSpace[m1],NullSpace[m2],NullSpace[m5]]; (* join bases of H^0(C,K)\otimes <x,y> and H^0(C,K)^{-5} *)

mtotal//MatrixForm;

Dimensions[mtotal]

MatrixRank[mtotal]