Skip to content

Instantly share code, notes, and snippets.

@8d1h
8d1h / chern_numbers.sage
Last active August 28, 2021 19:03
Chern numbers of K3^[n] in Sage
NTHREADS = 8 # use this to specify the number of threads
class TnVariety:
"""
A variety with a torus action for computing with Bott's formula
"""
def __init__(self, n, points, weight):
self.n = n
self.points = points
self.weight = weight
@8d1h
8d1h / LLV_decomposition.sage
Created July 23, 2021 17:51
LLV decomposition of hyperkähler cohomology in Sage
def hodge_num(d, V):
"""
Hodge numbers of a g-module V for a hyperkähler manifold of dimension d
"""
n = d / 2
m = V.weight_multiplicities()
M = matrix([[0 for i in range(d + 1)] for j in range(d + 1)])
for w in m:
M[w[0] + w[1] + n, w[0] - w[1] + n] += m[w]
return M