Skip to content

Instantly share code, notes, and snippets.

@pbelmans pbelmans/wps.sage
Created Nov 16, 2016

Embed
What would you like to do?
Understanding normalisation and basic properties of weighted projective spaces
import itertools
def reduce(Q):
return tuple([qi / gcd(Q) for qi in Q])
def normalise(Q):
Q = reduce(Q)
D = [gcd(Q[:i] + Q[i+1:]) for i in range(len(Q))]
A = [lcm(D[:i] + D[i+1:]) for i in range(len(Q))]
a = lcm(A)
return tuple([qi / ai for (qi, ai) in zip(Q, A)])
def isNormalised(Q):
return Q == normalise(Q)
def isGorenstein(Q):
return sum(Q) % lcm(Q) == 0
bound = 20
dimension = 2
#bound = 25
#dimension = 3
weights = itertools.product(range(1, bound), repeat=dimension+1)
weights = filter(lambda Q: Q == tuple(sorted(Q)), weights)
normalised = filter(isNormalised, weights)
Gorenstein = filter(isGorenstein, normalised)
print len(normalised)
print len(Gorenstein), Gorenstein
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.