def __init__(self, parent, x=None): """ INPUT: - ``parent`` -- a Hecke module - ``x`` -- element of the free module associated to parent EXAMPLES:: sage: v = sage.modular.hecke.all.HeckeModuleElement(BrandtModule(37), vector(QQ,[1,2,3])); v (1, 2, 3) sage: type(v) <class 'sage.modular.hecke.element.HeckeModuleElement'> TESTS:: sage: v = ModularSymbols(37).0 sage: loads(dumps(v)) (1,0) sage: loads(dumps(v)) == v True """ ModuleElement.__init__(self, parent) if x is not None: self.__element = x
def __init__(self, parent, d): r"""Do not call directly!""" # This should be a dict if not isinstance(d,dict): raise ValueError("RelativeHomologyClass.__init__ must be passed a dictionary.") self._d = d ModuleElement.__init__(self, parent=parent)
def __init__(self, parent, val=0, check=True, normalize=False): ModuleElement.__init__(self, parent) self._parent = parent self._depth = self._parent._depth if not check: self._val = val else: if isinstance(val, self.__class__): if val._parent._depth == parent._depth: self._val = val._val else: d = min([val._parent._depth, parent._depth]) self._val = val._val.submatrix(0, 0, nrows=d) elif isinstance(val, Vector_integer_dense) or isinstance( val, FreeModuleElement_generic_dense): self._val = MatrixSpace(self._parent._R, self._depth, 1)(0) for i, o in enumerate(val.list()): self._val[i, 0] = o else: try: self._val = Matrix(self._parent._R, self._depth, 1, val) except (TypeError, ValueError): self._val = self._parent._R(val) * MatrixSpace( self._parent._R, self._depth, 1)(1) self._moments = self._val
def __init__(self, parent, data): r''' Define an element of `H^1(G,V)` INPUT: - G: a BigArithGroup - V: a CoeffModule - data: a list TESTS:: sage: from darmonpoints.sarithgroup import BigArithGroup sage: from darmonpoints.cohomology_arithmetic import ArithCoh sage: G = BigArithGroup(5,6,1,use_shapiro=False,outfile='/tmp/darmonpoints.tmp') # optional - magma sage: Coh = ArithCoh(G) # optional - magma sage: 2 in Coh.hecke_matrix(13).eigenvalues() # optional - magma True sage: -4 in Coh.hecke_matrix(7).eigenvalues() # optional - magma True sage: PhiE = Coh.gen(1) # optional - magma ''' G = parent.group() V = parent.coefficient_module() if isinstance(data, list): self._val = [V(o) for o in data] else: self._val = [V(data.evaluate(b)) for b in parent.group().gens()] ModuleElement.__init__(self, parent)
def __init__(self, parent, data, check=True): V = parent.coefficient_module() if check: if isinstance(data, list): if data[0].parent() is V: self._val = [V(o) for o in data] else: dim = len(V.gens()) self._val = [] for i in range(0, dim * len(parent._G.coset_reps()), dim): self._val.append(V(data[i:i + dim])) elif isinstance(data, self.__class__): self._val = [V(o) for o in data._val] if hasattr(self._val[0], 'lift'): prec = self._val[0].parent().precision_cap() self._val = [o.lift(M=prec) for o in self._val] elif isinstance(data, Vector_integer_dense) or isinstance( data, Vector_rational_dense): data = list(data) dim = len(V.gens()) self._val = [] for i in range(0, dim * len(parent._G.coset_reps()), dim): self._val.append(V(data[i:i + dim])) else: self._val = [V(data) for o in parent._G.coset_reps()] assert len(self._val) == len(parent._G.coset_reps()) else: self._val = data ModuleElement.__init__(self, parent)
def __init__(self, parent, x=None): """ INPUT: - ``parent`` -- a Hecke module - ``x`` -- element of the free module associated to parent EXAMPLES:: sage: v = sage.modular.hecke.all.HeckeModuleElement(BrandtModule(37), vector(QQ,[1,2,3])); v (1, 2, 3) sage: type(v) <class 'sage.modular.hecke.element.HeckeModuleElement'> TESTS:: sage: v = ModularSymbols(37).0 sage: loads(dumps(v)) (1,0) sage: loads(dumps(v)) == v True """ ModuleElement.__init__(self, parent) if x is not None: self.__element = x
def __init__(self, parent, element, check=True): """ An element of a finite subgroup of a modular abelian variety. INPUT: - ``parent`` - a finite subgroup of a modular abelian variety - ``element`` - a QQ vector space element that represents this element in terms of the ambient rational homology - ``check`` - bool (default: True) whether to check that element is in the appropriate vector space EXAMPLES: The following calls the TorsionPoint constructor implicitly:: sage: J = J0(11) sage: G = J.finite_subgroup([[1/3,0], [0,1/5]]); G Finite subgroup with invariants [15] over QQbar of Abelian variety J0(11) of dimension 1 sage: type(G.0) <class 'sage.modular.abvar.finite_subgroup.TorsionPoint'> """ ModuleElement.__init__(self, parent) if check: if not element in parent.abelian_variety().vector_space(): raise TypeError, "element must be a vector in the abelian variety's rational homology (embedded in the ambient Jacobian product)" if element.denominator() == 1: element = element.parent().zero_vector() self.__element = element
def __init__(self, parent, element, check=True): """ An element of a finite subgroup of a modular abelian variety. INPUT: - ``parent`` - a finite subgroup of a modular abelian variety - ``element`` - a QQ vector space element that represents this element in terms of the ambient rational homology - ``check`` - bool (default: True) whether to check that element is in the appropriate vector space EXAMPLES: The following calls the TorsionPoint constructor implicitly:: sage: J = J0(11) sage: G = J.finite_subgroup([[1/3,0], [0,1/5]]); G Finite subgroup with invariants [15] over QQbar of Abelian variety J0(11) of dimension 1 sage: type(G.0) <class 'sage.modular.abvar.finite_subgroup.TorsionPoint'> """ ModuleElement.__init__(self, parent) if check: if not element in parent.abelian_variety().vector_space(): raise TypeError, "element must be a vector in the abelian variety's rational homology (embedded in the ambient Jacobian product)" if element.denominator() == 1: element = element.parent().zero_vector() self.__element = element
def __init__(self, parent, data): additive = parent.is_additive() K = parent.base_ring() prec = parent._prec p = K.prime() Ps = parent._Ps phi = parent._Ps_local_variable self._value = Ps(0) if additive else Ps(1) if data == 0: pass elif isinstance(data.parent(), Divisors): for Q, n in data: if Q.valuation() >= 0: raise ValueError( 'Divisor is not defined over the right open') if additive: self._value += n * phi(Q).log() else: self._value *= phi(Q)**n else: self._value = Ps(data) assert self._value.valuation() >= 0 assert min([o.valuation() for o in self._value.coefficients()]) >= 0 self._value.add_bigoh(prec) ModuleElement.__init__(self, parent)
def __init__(self, parent, x, check=DEBUG): """ INPUT: - ``parent`` -- parent module M - ``x`` -- element of M.V() - ``check`` -- (default: True) if True, verify that x in M.V() EXAMPLES:: sage: V = span([[1/2,1,1],[3/2,2,1],[0,0,1]],ZZ); W = V.span([2*V.0+4*V.1, 9*V.0+12*V.1, 4*V.2]) sage: Q = V/W sage: x = Q(V.0-V.1); type(x) <class 'sage.modules.fg_pid.fgp_element.FGP_Module_class_with_category.element_class'> sage: isinstance(x,sage.modules.fg_pid.fgp_element.FGP_Element) True For full documentation, see :class:`FGP_Element`. """ if check: assert x in parent.V( ), 'The argument x=' + str(x) + ' is not in the covering module!' ModuleElement.__init__(self, parent) self._x = x
def __init__(self, parent, data): r''' Define an element of `H^1(G,V)` INPUT: - G: a BigArithGroup - V: a CoeffModule - data: a list TESTS:: sage: from darmonpoints.sarithgroup import BigArithGroup sage: from darmonpoints.cohomology_arithmetic import ArithCoh sage: G = BigArithGroup(5,6,1,use_shapiro=False,outfile='/tmp/darmonpoints.tmp') # optional - magma sage: Coh = ArithCoh(G) # optional - magma sage: 2 in Coh.hecke_matrix(13).eigenvalues() # optional - magma True sage: -4 in Coh.hecke_matrix(7).eigenvalues() # optional - magma True sage: PhiE = Coh.gen(1) # optional - magma ''' G = parent.group() V = parent.coefficient_module() if isinstance(data,list): self._val = [V(o) for o in data] else: self._val = [V(data.evaluate(b)) for b in parent.group().gens()] ModuleElement.__init__(self,parent)
def __init__(self, field, f, t=None): """ Initialize the differential `fdt`. INPUT: - ``field`` -- function field - ``f`` -- element of the function field - ``t`` -- element of the function field; if `t` is not specified, `t` is the generator of the base rational function field EXAMPLES:: sage: F.<x>=FunctionField(GF(7)) sage: f = x / (x^2 + x + 1) sage: f.differential() ((6*x^2 + 1)/(x^4 + 2*x^3 + 3*x^2 + 2*x + 1)) d(x) sage: K.<x> = FunctionField(GF(4)); _.<Y> = K[] sage: L.<y> = K.extension(Y^3 + x + x^3*Y) sage: y.differential() (x*y^2 + 1/x*y) d(x) """ ModuleElement.__init__(self, field.space_of_differentials()) if t is not None: der = field.derivation() f *= der(t) self._field = field self._f = f
def __init__(self, parent, data, check = True): V = parent.coefficient_module() if check: if isinstance(data,list): if data[0].parent() is V: self._val = [V(o) for o in data] else: dim = len(V.gens()) self._val = [] for i in range(0,dim * len(parent._G.coset_reps()),dim): self._val.append(V(data[i:i+dim])) elif isinstance(data, self.__class__): self._val = [V(o) for o in data._val] if hasattr(self._val[0],'lift'): prec = self._val[0].parent().precision_cap() self._val = [o.lift(M = prec) for o in self._val] elif isinstance(data, Vector_integer_dense) or isinstance(data, Vector_rational_dense): data = list(data) dim = len(V.gens()) self._val = [] for i in range(0,dim * len(parent._G.coset_reps()),dim): self._val.append(V(data[i:i+dim])) else: self._val = [V(data) for o in parent._G.coset_reps()] assert len(self._val) == len(parent._G.coset_reps()) else: self._val = data ModuleElement.__init__(self,parent)
def __init__(self, parent, d): r"""Do not call directly!""" # This should be a dict if not isinstance(d, dict): raise ValueError( "RelativeHomologyClass.__init__ must be passed a dictionary.") self._d = d ModuleElement.__init__(self, parent=parent)
def __init__(self, parent, val=0, check=True, normalize=False): """ Initialisation function. Takes as input a vector val, which should have length equal to the dimension of the space, which is the nth triangle number, where n is the depth. This corresponds to the ordered basis for distributions (namely, the dual basis to the basis 1, x, y, x^2, xy, ...). Input: - parent: BianchiDistributions object of depth n - val : vector of length n^2 encoding the moments of the distribution """ ## Parents/precision ModuleElement.__init__(self, parent) self._parent = parent self._depth = self._parent._depth self._dimension = self._parent._dimension ## check multiple possibilities for input if not check: self._moments = val else: ## is input already a distribution? if isinstance(val, self.__class__): ## if depth is the same, then keep this if val._parent._depth == parent._depth: self._moments = val._moments else: ## depths are different, take the minimum d = min([val.nrows(), parent.dimension()]) self._moments = val._moments.submatrix(0, 0, nrows=d) elif isinstance(val, int) or isinstance(val, Integer): ## Initialise distribution to be trivial, i.e. constant moment = input and rest = 0 self._moments = MatrixSpace(self._parent._R, self._dimension, 1)(0) self._moments[0, 0] = val ## input is a vector storing the moments elif isinstance(val, Vector_integer_dense) or isinstance( val, FreeModuleElement_generic_dense): self._moments = MatrixSpace(self._parent._R, self._dimension, 1)(0) for i, o in enumerate(val.list()): self._moments[i, 0] = o ## input is a list storing the moments elif isinstance(val, list): self._moments = MatrixSpace(self._parent._R, self._dimension, 1)(0) for i, o in enumerate(val): self._moments[i, 0] = o else: try: self._moments = Matrix(self._parent._R, self._depth, 1, val) except (TypeError, ValueError): self._moments = self._parent._R(val) * MatrixSpace( self._parent._R, self._dimension, 1)(1)
def __init__(self, x, parent=None, check=True, reduce=True): """ INPUT: - ``x`` -- object - ``parent`` -- FormalSums(R) module (default: FormalSums(ZZ)) - ``check`` -- bool (default: True) if False, might not coerce coefficients into base ring, which can speed up constructing a formal sum. - ``reduce`` -- reduce (default: True) if False, do not combine common terms EXAMPLES:: sage: FormalSum([(1,2/3), (3,2/3), (-5, 7)]) 4*2/3 - 5*7 sage: a = FormalSum([(1,2/3), (3,2/3), (-5, 7)], reduce=False); a 2/3 + 3*2/3 - 5*7 sage: a.reduce() sage: a 4*2/3 - 5*7 sage: FormalSum([(1,2/3), (3,2/3), (-5, 7)], parent=FormalSums(GF(5))) 4*2/3 Notice below that the coefficient 5 doesn't get reduced modulo 5:: sage: FormalSum([(1,2/3), (3,2/3), (-5, 7)], parent=FormalSums(GF(5)), check=False) 4*2/3 - 5*7 Make sure we first reduce before checking coefficient types:: sage: x,y = var('x, y') sage: FormalSum([(1/2,x), (2,y)], FormalSums(QQ)) 1/2*x + 2*y sage: FormalSum([(1/2,x), (2,y)], FormalSums(ZZ)) Traceback (most recent call last): ... TypeError: no conversion of this rational to integer sage: FormalSum([(1/2,x), (1/2,x), (2,y)], FormalSums(ZZ)) x + 2*y """ if x == 0: x = [] self._data = x if parent is None: parent = formal_sums ModuleElement.__init__(self, parent) assert isinstance(parent, parent.category().parent_class) if reduce: # first reduce self.reduce() if check: # then check k = parent.base_ring() try: self._data = [(k(t[0]), t[1]) for t in self._data] except (IndexError, KeyError) as msg: raise TypeError("%s\nInvalid formal sum"%msg)
def __init__(self, x, parent=None, check=True, reduce=True): """ INPUT: - ``x`` -- object - ``parent`` -- FormalSums(R) module (default: FormalSums(ZZ)) - ``check`` -- bool (default: True) if False, might not coerce coefficients into base ring, which can speed up constructing a formal sum. - ``reduce`` -- reduce (default: True) if False, do not combine common terms EXAMPLES:: sage: FormalSum([(1,2/3), (3,2/3), (-5, 7)]) 4*2/3 - 5*7 sage: a = FormalSum([(1,2/3), (3,2/3), (-5, 7)], reduce=False); a 2/3 + 3*2/3 - 5*7 sage: a.reduce() sage: a 4*2/3 - 5*7 sage: FormalSum([(1,2/3), (3,2/3), (-5, 7)], parent=FormalSums(GF(5))) 4*2/3 Notice below that the coefficient 5 doesn't get reduced modulo 5:: sage: FormalSum([(1,2/3), (3,2/3), (-5, 7)], parent=FormalSums(GF(5)), check=False) 4*2/3 - 5*7 Make sure we first reduce before checking coefficient types:: sage: x,y = var('x, y') sage: FormalSum([(1/2,x), (2,y)], FormalSums(QQ)) 1/2*x + 2*y sage: FormalSum([(1/2,x), (2,y)], FormalSums(ZZ)) Traceback (most recent call last): ... TypeError: no conversion of this rational to integer sage: FormalSum([(1/2,x), (1/2,x), (2,y)], FormalSums(ZZ)) x + 2*y """ if x == 0: x = [] self._data = x if parent is None: parent = formal_sums ModuleElement.__init__(self, parent) assert isinstance(parent, parent.category().parent_class) if reduce: # first reduce self.reduce() if check: # then check k = parent.base_ring() try: self._data = [(k(t[0]), t[1]) for t in self._data] except (IndexError, KeyError) as msg: raise TypeError("%s\nInvalid formal sum" % msg)
def __init__(self, parent, data): r''' Define an element of `H_1(G,V)` - data: a list TESTS: ''' if not isinstance(data, dict): raise ValueError, 'data should be a dictionary indexed by elements of ArithGroup' self._data = data ModuleElement.__init__(self, parent)
def __init__(self, parent, data): """ Initialize. TESTS:: sage: K.<x> = FunctionField(GF(2)); _.<Y> = K[] sage: L.<y> = K.extension(Y^3 + x + x^3*Y) sage: G = L.divisor_group() sage: TestSuite(G).run() """ ModuleElement.__init__(self, parent) self._data = data
def __init__(self, parent, vectors): """ Initialize ``self``. EXAMPLES:: sage: F.<x,y> = FreeAlgebra(ZZ) sage: H = F.hochschild_complex(F) sage: a = H({0: x-y, 2: H.module(2).basis().an_element()}) sage: TestSuite(a).run() """ self._vec = vectors ModuleElement.__init__(self, parent)
def __init__(self, parent, vectors): """ Initialize ``self``. EXAMPLES:: sage: F.<x,y> = FreeAlgebra(ZZ) sage: H = F.hochschild_complex(F) sage: a = H({0: x-y, 2: H.module(2).basis().an_element()}) sage: TestSuite(a).run() """ self._vec = vectors ModuleElement.__init__(self, parent)
def __init__(self,_parent,vec,quick=False): ModuleElement.__init__(self,_parent) self._parent=_parent self._nE=2*len(_parent._E) # We record the values at the opposite edges self._cached_values=dict() self._R=Qp(_parent._X._p,prec=_parent._prec) if(quick): self._F=[v for v in vec] else: if(isinstance(vec,pAutomorphicForm)): self._F=[self._parent._U(vec._F[ii]) for ii in range(self._nE)] self._make_invariant() elif(isinstance(vec,HarmonicCocycleElement)): assert(_parent._U.weight()==vec._wt-2) self._F=[] assert(2*len(vec._F)==self._nE) assert(isinstance(_parent._U,OCVn)) E=self._parent._E MMM=vec._parent._U.element_class tmp=[] for ii in range(len(vec._F)): newtmp=MMM(vec._parent._U,vec._F[ii]).l_act_by(E[ii].rep.inverse()) tmp.append(newtmp) self._F.append(_parent._U(newtmp)) A=Matrix(QQ,2,2,[0,-1/_parent._X._p,-1,0]) for ii in range(len(vec._F)): self._F.append(_parent._U(-1*tmp[ii].r_act_by(A))) self._make_invariant() elif(isinstance(vec,list) and len(vec)==self._nE): try: self._F=[self._parent._U(v) for v in vec] except: try: veczp=_parent._U._R(vec) self._parent=_parent self._F=[self._parent._U(veczp) for ii in range(self._nE)] except: print vec assert(0) else: try: veczp=_parent._U._R(vec) self._parent=_parent self._F=[self._parent._U(veczp) for ii in range(self._nE)] except: raise ValueError,"Cannot initialize a p-adic automorphic form with the given input="+str(vec)
def __init__(self, parent, data, ptdata=None): r''' A Divisor is given by a list of pairs (P,nP), where P is a point, and nP is an integer. TESTS: sage: from darmonpoints.homology import Divisors sage: Cp.<g> = Qq(5^3,20) sage: Div = Divisors(Cp) sage: D1 = Div(g+3) sage: D2 = Div(2*g+1) sage: D = D1 + D2 sage: print(-D) Divisor of degree -2 sage: print(2*D1 + 5*D2) Divisor of degree 7 ''' self._data = defaultdict(ZZ) self._ptdict = {} ModuleElement.__init__(self, parent) if data == 0: return elif isinstance(data, DivisorsElement): self._data.update(data._data) self._ptdict.update(data._ptdict) elif isinstance(data, list): for n, P in data: if n == 0: continue hP = _hash(P) self._data[hP] += n self._ptdict[hP] = P if self._data[hP] == 0: del self._data[hP] del self._ptdict[hP] elif isinstance(data, dict): assert ptdata is not None self._data.update(data) self._ptdict.update(ptdata) else: if data != Infinity: P = self.parent().base_field()(data) else: P = data hP = _hash(P) self._data[hP] = 1 self._ptdict[hP] = P
def __init__(self,parent,vec,quick = False): ModuleElement.__init__(self,parent) self._num_generators = len(parent._list) self._cached_values = dict() self._R = Qp(parent.prime(),prec = parent._prec) if quick: # assert vec[0].parent() == parent._U self._value = [ parent._U(v) for v in vec ] else: if isinstance(vec,pAutomorphicFormElement): self._value = parent._make_invariant([parent._U(vec._value[ii]) for ii in range(self._num_generators)]) elif isinstance(vec,HarmonicCocycleElement): assert(parent._U.weight() == vec._wt-2) F = [] assert(2*len(vec._F) == self._num_generators) assert(isinstance(parent._U,OCVn)) E = parent._list MMM = vec.parent()._U.element_class tmp = [] for ii in range(len(vec._F)): newtmp = MMM(vec.parent()._U,vec._F[ii]).l_act_by(E[ii].rep.inverse()) tmp.append(newtmp) F.append(parent._U(newtmp)) A = Matrix(QQ,2,2,[0,-1/parent.prime(),-1,0]) for ii in range(len(vec._F)): F.append(parent._U(-1*tmp[ii].r_act_by(A))) self._value = parent._make_invariant(F) elif isinstance(vec,list) and len(vec) == self._num_generators: try: self._value = [parent._U(v) for v in vec] except: try: veczp = parent._U._R(vec) self._value = [parent._U(veczp) for ii in range(self._num_generators)] except: print vec assert(0) else: try: veczp = parent._U._R(vec) self._value = [parent._U(veczp) for ii in range(self._num_generators)] except: raise ValueError,"Cannot initialize a p-adic automorphic form with the given input = "+str(vec)
def __init__(self, parent, coefficient=None, valuation=0, constant=None): """ Initialize. TESTS:: sage: L = LazyLaurentSeriesRing(GF(2), 'z') sage: z = L.gen() sage: TestSuite(z).run() """ ModuleElement.__init__(self, parent) self._coefficient_function = coefficient self._approximate_valuation = valuation self._constant = constant self._cache = dict() # cache of known coefficients
def __init__(self, parent, f, t=None): """ Initialize the differential `fdt`. TESTS:: sage: F.<x> = FunctionField(GF(7)) sage: f = x/(x^2 + x + 1) sage: w = f.differential() sage: TestSuite(w).run() """ ModuleElement.__init__(self, parent) if t is not None: f *= parent._derivation(t) * parent._gen_derivative_inv self._f = f
def __init__(self, parent, element, check=True): """ Initialize ``self``. EXAMPLES:: sage: J = J0(11) sage: G = J.finite_subgroup([[1/2,0], [0,1/2]]) sage: TestSuite(G).run() # long time """ ModuleElement.__init__(self, parent) if check: if element not in parent.abelian_variety().vector_space(): raise TypeError("element must be a vector in the abelian variety's rational homology (embedded in the ambient Jacobian product)") if element.denominator() == 1: element = element.parent().zero_vector() self.__element = element
def __init__(self, parent, val=0, check=False): ModuleElement.__init__(self, parent) self._parent = parent self._n = self._parent._n self._nhalf = Integer(self._n / 2) self._depth = self._parent._depth if check: if isinstance(val, self.__class__): d = min([val._parent._depth, parent._depth]) assert val._parent.weight() == parent.weight() self._val = Matrix(self._parent._R, self._depth, 1, 0) for ii in range(d): self._val[ii, 0] = val._val[ii, 0] else: try: self._val = MatrixSpace(self._parent._R, self._depth, 1)(val) except: self._val = val * ones_matrix(self._parent._R, self._depth, 1) self._val = copy(val)
def __init__(self, parent, precision, coefficient_function, components, bounding_precision ) : r""" INPUT: - ``parent`` -- An instance of :class:~`fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ambient.MonoidPowerSeriesAmbient_abstract`. - ``precision`` -- A filter for the parent's action. - ``coefficient_function`` -- A function returning for each pair of characters and monoid element a Fourier coefficients. - ``components`` -- ``None`` or a list of characters. A list of components that do not vanish. If ``None`` no component is assumed to be zero. TESTS:: sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_lazyelement import * sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_module import * sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import * sage: m = FreeModule(QQ, 3) sage: emps = EquivariantMonoidPowerSeriesModule( NNMonoid(), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", m) ) sage: h = EquivariantMonoidPowerSeries_moduleelement_lazy(emps, emps.action().filter(3), lambda (ch, k) : m([1,2,3]), None, None) """ ModuleElement.__init__(self, parent) EquivariantMonoidPowerSeries_abstract_lazy.__init__(self, parent, precision, coefficient_function, components, bounding_precision)
def __init__(self, parent, precision, coefficient_function, components, bounding_precision ) : r""" INPUT: - ``parent`` -- An instance of :class:~`fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ambient.MonoidPowerSeriesAmbient_abstract`. - ``precision`` -- A filter for the parent's action. - ``coefficient_function`` -- A function returning for each pair of characters and monoid element a Fourier coefficients. - ``components`` -- ``None`` or a list of characters. A list of components that do not vanish. If ``None`` no component is assumed to be zero. TESTS:: sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_lazyelement import * sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_module import * sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import * sage: m = FreeModule(QQ, 3) sage: emps = EquivariantMonoidPowerSeriesModule( NNMonoid(), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", m) ) sage: h = EquivariantMonoidPowerSeries_moduleelement_lazy(emps, emps.action().filter(3), lambda (ch, k) : m([1,2,3]), None, None) """ ModuleElement.__init__(self, parent) EquivariantMonoidPowerSeries_abstract_lazy.__init__(self, parent, precision, coefficient_function, components, bounding_precision)
def __init__(self, parent, val=0, quick=False): ModuleElement.__init__(self, parent) self._parent = parent self._n = self._parent._n self._nhalf = Integer(self._n / 2) self._depth = self._parent._depth if quick: self._val = val else: if isinstance(val, self.__class__): d = min([val._parent._depth, parent._depth]) assert (val._parent.weight() == parent.weight()) self._val = Matrix(self._parent._R, self._depth, 1, 0) for ii in range(d): self._val[ii, 0] = val._val[ii, 0] else: try: self._val = MatrixSpace(self._parent._R, self._depth, 1)(val) except: self._val = val * ones_matrix(self._parent._R, self._depth, 1)
def __init__(self, parent, data, check=True): if check: additive = parent.is_additive() K = parent.base_ring() prec = parent._prec p = K.prime() Ps = parent._Ps phi = parent._Ps_local_variable if data == 0: self._value = parent._V(0) if additive else Ps(1) elif isinstance(data.parent(), Divisors): self._value = parent._V(0) if additive else Ps(1) for Q, n in data: if Q.valuation() >= 0: raise ValueError( 'Divisor is not defined over the right open') if additive: if parent._dlog: self._value += n * parent._V( (phi(K(Q)).log().derivative()).list()) else: self._value += n * parent._V( (phi(K(Q)).log()).list()) else: self._value *= phi(K(Q))**n elif data.parent() == parent._V: self._value = parent._V(data) else: val = Ps(data) val.add_bigoh(prec) if additive: self._value = self.parent()._V(val.list()) else: self._value = val else: self._value = data # assert min([o.valuation() for o in self._value.list()]) >= 0 self._moments = self._value ModuleElement.__init__(self, parent)
def __init__(self, parent, polynomial): r""" INPUT: - ``parent`` -- An instance of :class:~`fourier_expansion_framework.gradedexpansions.gradedexpansion_module.GradedExpansionModule_class`. - ``polynomial`` -- A polynomial in the polynomial ring underlying the parent. TESTS:: sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import * sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_module import * sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_element import * sage: from psage.modform.fourier_expansion_framework.gradedexpansions.gradedexpansion_grading import DegreeGrading sage: from psage.modform.fourier_expansion_framework.gradedexpansions.gradedexpansion_module import * sage: from psage.modform.fourier_expansion_framework.gradedexpansions.gradedexpansion_element import * sage: m = FreeModule(QQ, 3) sage: mpsm = MonoidPowerSeriesModule(m, NNMonoid(False)) sage: mps = mpsm.base_ring() sage: P.<a,b> = QQ[] sage: ger = GradedExpansionModule_class(Sequence([MonoidPowerSeries(mps, {1: 1}, mps.monoid().filter(4))]), Sequence([MonoidPowerSeries(mpsm, {1: m([1,1,1]), 2: m([1,3,-3])}, mpsm.monoid().filter(4))]), P.ideal(0), DegreeGrading((1,2))) sage: h = GradedExpansionVector_class(ger, a) """ ModuleElement.__init__(self, parent) GradedExpansion_abstract.__init__(self, parent, polynomial)
def __init__(self, parent, polynomial) : r""" INPUT: - ``parent`` -- An instance of :class:~`fourier_expansion_framework.gradedexpansions.gradedexpansion_module.GradedExpansionModule_class`. - ``polynomial`` -- A polynomial in the polynomial ring underlying the parent. TESTS:: sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import * sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_module import * sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_element import * sage: from psage.modform.fourier_expansion_framework.gradedexpansions.gradedexpansion_grading import DegreeGrading sage: from psage.modform.fourier_expansion_framework.gradedexpansions.gradedexpansion_module import * sage: from psage.modform.fourier_expansion_framework.gradedexpansions.gradedexpansion_element import * sage: m = FreeModule(QQ, 3) sage: mpsm = MonoidPowerSeriesModule(m, NNMonoid(False)) sage: mps = mpsm.base_ring() sage: P.<a,b> = QQ[] sage: ger = GradedExpansionModule_class(Sequence([MonoidPowerSeries(mps, {1: 1}, mps.monoid().filter(4))]), Sequence([MonoidPowerSeries(mpsm, {1: m([1,1,1]), 2: m([1,3,-3])}, mpsm.monoid().filter(4))]), P.ideal(0), DegreeGrading((1,2))) sage: h = GradedExpansionVector_class(ger, a) """ ModuleElement.__init__(self, parent) GradedExpansion_abstract.__init__(self, parent, polynomial)
def __init__(self, parent, terms): """ Kontsevich graph sum. A formal sum of Kontsevich graphs, modulo the relation that swapping two edges (L and R) originating from an internal vertex introduces a minus sign. INPUT: - ``parent`` -- a ``KontsevichGraphSums`` module. - ``terms`` -- list of ``(coefficient, graph)`` tuples, where ``coefficient`` is in ``parent.base_ring()``, and ``graph`` is an immutable KontsevichGraph. OUTPUT: A formal sum of Kontsevich graphs. EXAMPLES:: sage: K = KontsevichGraphSums(QQ) sage: KG = KontsevichGraph(ground_vertices=(), immutable=True) sage: KontsevichGraphSum(K, [(1/2, KG)]) 1/2*(Kontsevich graph with 0 vertices on 0 ground vertices) """ if terms == 0: terms = [] if not isinstance(terms, list): raise TypeError('Input must be a list of terms.') if not all(isinstance(t, tuple) and len(t) == 2 for t in terms): raise TypeError('Terms must be (coefficient, graph) tuples.') if not all(c in parent.base_ring() and isinstance(g, KontsevichGraph) and getattr(g, '_immutable', False) for (c,g) in terms): raise TypeError('Coefficients must be in base ring, and ' + 'graphs must be immutable KontsevichGraphs.') self._terms = terms ModuleElement.__init__(self, parent=parent)
def __init__(self, parent, x, check=DEBUG): """ INPUT: - ``parent`` -- parent module M - ``x`` -- element of M.V() - ``check`` -- (default: True) if True, verify that x in M.V() EXAMPLES:: sage: V = span([[1/2,1,1],[3/2,2,1],[0,0,1]],ZZ); W = V.span([2*V.0+4*V.1, 9*V.0+12*V.1, 4*V.2]) sage: Q = V/W sage: x = Q(V.0-V.1); type(x) <class 'sage.modules.fg_pid.fgp_element.FGP_Module_class_with_category.element_class'> sage: isinstance(x,sage.modules.fg_pid.fgp_element.FGP_Element) True For full documentation, see :class:`FGP_Element`. """ if check: assert x in parent.V(), 'The argument x='+str(x)+' is not in the covering module!' ModuleElement.__init__(self, parent) self._x = x
class FormalSum(ModuleElement): def __init__(self, x, parent=formal_sums, check=True, reduce=True): if x == 0: x = [] if check: k = parent.base_ring() try: x = [(k(t[0]), t[1]) for t in x] except (IndexError, KeyError), msg: raise TypeError, "%s\nInvalid formal sum" % msg self._data = x if parent is None: parent = formal_sums ModuleElement.__init__(self, parent) self.reduce()
def __init__(self,parent,val = 0,check = True,normalize=False): ModuleElement.__init__(self,parent) self._parent = parent self._depth = self._parent._depth if not check: self._val = val else: if isinstance(val,self.__class__): if val._parent._depth == parent._depth: self._val = val._val else: d = min([val._parent._depth,parent._depth]) self._val = val._val.submatrix(0,0,nrows = d) elif isinstance(val, Vector_integer_dense) or isinstance(val, FreeModuleElement_generic_dense): self._val = MatrixSpace(self._parent._R, self._depth, 1)(0) for i,o in enumerate(val.list()): self._val[i,0] = o else: try: self._val = Matrix(self._parent._R,self._depth,1,val) except (TypeError, ValueError): self._val= self._parent._R(val) * MatrixSpace(self._parent._R,self._depth,1)(1) self._moments = self._val
def __init__(self, parent, polynomial): r""" INPUT: - ``parent`` - a quasimodular forms ring - ``polynomial`` - a polynomial `f_0 + f_1 E_2 + ... + f_n E_2^n` where each `f_i` are modular forms ring elements and `E_2` correspond to the weight 2 Eisenstein series OUTPUT: ``QuasiModularFormsElement`` TESTS:: sage: QM = QuasiModularForms(1) sage: QM.element_class(QM, 'E2') Traceback (most recent call last): ... TypeError: 'polynomial' argument should be of type 'Polynomial' sage: x = polygen(QQ) sage: QM.element_class(QM, x^2 + 1) Traceback (most recent call last): ... ValueError: at least one coefficient is not a 'GradedModularFormElement' """ if not isinstance(polynomial, Polynomial): raise TypeError( "'polynomial' argument should be of type 'Polynomial'") for f in polynomial.coefficients(): if not isinstance(f, GradedModularFormElement): raise ValueError( "at least one coefficient is not a 'GradedModularFormElement'" ) self._polynomial = polynomial ModuleElement.__init__(self, parent)
def __init__(self, field, data): """ Initialize. INPUT: - ``field`` -- functon field - ``data`` -- dict of place and multiplicity pairs EXAMPLES:: sage: K.<x> = FunctionField(GF(2)); R.<t> = K[] sage: F.<y> = K.extension(t^3 - x^2*(x^2 + x + 1)^2) sage: f = x/(y+1) sage: f.divisor() Place (1/x, 1/x^4*y^2 + 1/x^2*y + 1) + Place (1/x, 1/x^2*y + 1) + 3*Place (x, (1/(x^3 + x^2 + x))*y^2) - 6*Place (x + 1, y + 1) """ ModuleElement.__init__(self, field.divisor_group()) self._field = field self._data = data
def __init__(self, map_data, parent, construct = False): ModuleElement.__init__(self, parent) if construct: self._map = map_data else: self._map = ManinMap(parent._coefficients, parent._source, map_data)
def __init__(self, map_data, parent, construct=False): ModuleElement.__init__(self, parent) if construct: self._map = map_data else: self._map = ManinMap(parent._coefficients, parent._source, map_data)