def glue_mori(DtoJmat, mori_rows_group): "Compute Mori and Kahler cones for glued geometries." g_mori = Cone(mori_rows_group[0]) for x in mori_rows_group[1:]: g_mori = g_mori.intersection(Cone(x)) g_mori_rows = [list(x) for x in g_mori.rays().column_matrix().columns()] g_mori_cols = mongojoin.transpose_list(g_mori_rows) g_kahler_cols = [ sum([ DtoJmat[k][j] * vector(g_mori_cols[j]) for j in range(len(g_mori_cols)) ]) for k in range(len(DtoJmat)) ] g_kahler_rows = mongojoin.transpose_list(g_kahler_cols) return [g_mori_rows, g_kahler_rows]
def ToricSwissCheese(h11,NL,dresverts,fgp,fav,JtoDmat,mori_rows,itensXD): "Solves for the rotation matrices of a Toric Swiss Cheese solution." if fav: mori_cols=mongojoin.transpose_list(mori_rows); ndivsD=len(JtoDmat); RaLbssetpairs=[]; #Small Cycle for i in range(ndivsD): for j in range(ndivsD): if (all([x==0 for x in itensXD[i][j]])): RaLbssetpairs+=[[{i},{j}]]; #Take (NL,h11-NL) subsets that satisfy the small cycle condition RaLbsgroups=groupabsetpairs(RaLbssetpairs,NL,h11); #Check for orthogonality (required for a basis) and basis change conditions #Rabgroups=[]; #Tab=[]; result=[]; homresult=[]; #rind=0; #ind=0; #int_basis_a=False; #int_basis_b=False; doneflag=False; for group in RaLbsgroups: aspossset=Set([z for z in range(ndivsD) if z not in group[0]]).subsets(h11-NL).list(); bLpossset=Set([z for z in range(ndivsD) if z not in group[1]]).subsets(NL).list(); for asposs in aspossset: afullrank=(matrix(ZZ,[JtoDmat[j] for j in group[0]+list(asposs)]).rank()==h11); if afullrank: for bLposs in bLpossset: bfullrank=(matrix(ZZ,[JtoDmat[j] for j in list(bLposs)+group[1]]).rank()==h11); if bfullrank: r=[[group[0],list(asposs)],[list(bLposs),group[1]]]; ra=r[0][0]+r[0][1]; #Volume volflag=False; lkconeflag=False; skconeflag=False; lcflag=False; homflag=False; i=0; while (i<len(r[0][0]) and not volflag): j=0; while (j<len(ra) and not volflag): k=0; while (k<len(ra) and not volflag): if (itensXD[r[0][0][i]][ra[j]][ra[k]]!=0): volflag=True; k+=1; j+=1; i+=1; if volflag: #Kahler Cone (Large part) lkconeflag=all([(all([y>=0 for y in mori_cols[z]]) or all([y<=0 for y in mori_cols[z]])) for z in r[0][0]]); if lkconeflag: #Kahler Cone (Small part) #skconeflag=False; #all_solcones=[Cone([[mori_rows[i][r[0][1][j]] for j in range(len(r[0][1]))]]).dual() for i in range(len(mori_rows)) if all([mori_rows[i][k]==0 for k in r[0][0]])]; #solcone=Cone([[0 for j in range(len(r[0][1]))]]).dual(); #for newsolcone in all_solcones: # solcone=solcone.intersection(newsolcone); #if solcone.dim()==len(r[0][1]): # skconeflag=True; #else: # in_interior=(not any([solcone.intersection(z).is_equivalent(solcone) for y in all_solcones for z in y.facets()])); # if in_interior: # skconeflag=True; skconeflag=Cone([[mori_rows[i][r[0][1][j]] for j in range(len(r[0][1]))] for i in range(len(mori_rows)) if all([mori_rows[i][k]==0 for k in r[0][0]])]).is_strictly_convex(); if skconeflag: #Large Cycle #lcflag=False; for j in r[0][0]: for k in ra: if (not any([itensXD[i][j][k]==0 for i in r[1][0]])): lcflag=True; break; if lcflag: break; if lcflag: #Homogeneity #if homogeneity_on: #homflag=False; for j in r[0][1]: if(not any([itensXD[i][i][j]==0 for i in r[1][1]])): homflag=True; break; #else: # homflag=True; if (volflag and lkconeflag and skconeflag and lcflag):# and homflag): #Convert to rotation matrices Ta=[JtoDmat[j] for j in r[0][0]+r[0][1]]; Tb=[JtoDmat[j] for j in r[1][0]+r[1][1]]; #Rabgroups+=[r]; #Tab+=[[Ta,Tb]]; #Check for integer bases a_integer=simpvol([dresverts[m] for m in range(ndivsD) if m not in r[0][0]+r[0][1]])==fgp; b_integer=simpvol([dresverts[m] for m in range(ndivsD) if m not in r[1][0]+r[1][1]])==fgp; result+=[[NL,[Ta,Tb],a_integer,b_integer,homflag]]; if homflag: homresult+=[[NL,[Ta,Tb],a_integer,b_integer,homflag]]; if a_integer and b_integer: #int_basis_a=True; #int_basis_b=True; #ind=rind; doneflag=True; break; #elif a_integer and (not b_integer) and not (int_basis_a or int_basis_b): # int_basis_a=True; # int_basis_b=False; # ind=rind; #elif (not a_integer) and b_integer and not (int_basis_a or int_basis_b): # int_basis_a=False; # int_basis_b=True; # ind=rind; #rind+=1; if doneflag: break; if doneflag: break; #if len(Tab)==0: # return [NL,[],int_basis_a,int_basis_b]; #else: # return [NL,Tab[ind],int_basis_a,int_basis_b]; if doneflag: return [NL,[Ta,Tb],a_integer,b_integer,homflag]; elif len(homresult)>0: return homresult[0]; elif len(result)>0: return result[0]; else: return [NL,[],False,False,False]; else: return [NL,"unfav",False,False,False];
Iprechow = C.ideal(Ilin + Ibasechange) ######################## Begin parallel MPI scatter/gather of geometrical information ############################### scatt = [[C, DD, JJ, dresverts, DtoJmat, Iprechow, x] for x in mongojoin.distribcores(triangs, size)] #If fewer cores are required than are available, pass extraneous cores no information if len(scatt) < size: scatt += [-2 for x in range(len(scatt), size)] #Scatter and define rank-independent input variables prechow = comm.scatter(scatt, root=0) C_chunk, DD_chunk, JJ_chunk, dresverts_chunk, DtoJmat_chunk, Iprechow_chunk, triangs_chunk = prechow #For each chunk of information assigned to this rank, do the following gath = [] for t in triangs_chunk: #Obtain Mori and Kahler matrices mori_rows = mori(dresverts_chunk, t['TRIANG']) mori_cols = mongojoin.transpose_list(mori_rows) kahler_cols = [ sum([ DtoJmat_chunk[k][j] * vector(mori_cols[j]) for j in range(len(mori_cols)) ]) for k in range(len(DtoJmat_chunk)) ] kahler_rows = mongojoin.transpose_list(kahler_cols) #Obtain Stanley-Reisner ideal and Chow ideal SR = SR_ideal(dresverts_chunk, t['TRIANG']) SRid = [prod([DD_chunk[j] for j in x]) for x in SR] ISR = C_chunk.ideal(SRid) Ichow = Iprechow_chunk + ISR #Obtain information about the Chow ring ipolyAD, itensAD, ipolyXD, itensXD, invbasis, JtoDmat, cnAD, cnAJ = chowAmb( C_chunk, DD_chunk, JJ_chunk, dresverts_chunk, t['TRIANG'],