Files
Calabi-Yau-Period-Geometry/sage/period_computation.sage
T
2026-08-15 15:16:35 +02:00

28 lines
1.1 KiB
Python

import logging
from sage.all import sage_eval, PolynomialRing, QQ
class PFOperator:
"""
A class representing a Picard-Fuchs operator in a single variable z.
Independent of the given order, the variables are assumed to be left of
the derivatives.
"""
def _operator_from_string(self, operator_string):
z_names = ['z%d' % i for i in range(self.no_variables)]
theta_names = ['theta%d' % i for i in range(self.no_variables)]
self.ring = PolynomialRing(QQ, z_names + theta_names)
self.z_gens = self.ring.gens()[:self.no_variables]
self.theta_gens = self.ring.gens()[self.no_variables:]
try:
operator = sage_eval(operator_string, locals=self.ring.gens_dict())
except Exception as e:
raise ValueError("Invalid operator string: %s" % e)
return self.ring(operator)
def __init__(self, operator_string, no_variables=1):
self.no_variables = no_variables
self.operator = self._operator_from_string(operator_string)
logging.debug("Initialized PFOperator: %s", self.operator)