{{ message }}

Instantly share code, notes, and snippets.

# pbelmans/wps.sage

Created Nov 16, 2016
Understanding normalisation and basic properties of weighted projective spaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 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