Initial setup for period computation #13
@@ -0,0 +1,25 @@
|
||||
import logger
|
||||
from sage.all import sage_eval, PolynomialRing, QQ
|
||||
|
||||
class PFOperator:
|
||||
"""
|
||||
A class representing a Picard-Fuchs operator in a single variable z.
|
||||
"""
|
||||
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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user