本文整理汇总了Python中sage.structure.element.ModuleElement类的典型用法代码示例。如果您正苦于以下问题:Python ModuleElement类的具体用法?Python ModuleElement怎么用?Python ModuleElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ModuleElement类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
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
开发者ID:mcognetta,项目名称:sage,代码行数:26,代码来源:element.py
示例2: __init__
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)
开发者ID:mmasdeu,项目名称:darmonpoints,代码行数:28,代码来源:representations.py
示例3: __init__
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
开发者ID:pombredanne,项目名称:sage-1,代码行数:33,代码来源:finite_subgroup.py
示例4: __init__
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)
开发者ID:mmasdeu,项目名称:darmonpoints,代码行数:28,代码来源:cohomology_abstract.py
示例5: __init__
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)
开发者ID:videlec,项目名称:sage-flatsurf,代码行数:7,代码来源:relative_homology.py
示例6: __init__
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)
开发者ID:mcognetta,项目名称:sage,代码行数:55,代码来源:formal_sum.py
示例7: __init__
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)
开发者ID:mcognetta,项目名称:sage,代码行数:13,代码来源:hochschild_complex.py
示例8: __init__
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)
开发者ID:williamstein,项目名称:OMS,代码行数:50,代码来源:pautomorphicform.py
示例9: __init__
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)
开发者ID:mmasdeu,项目名称:btquotients,代码行数:47,代码来源:pautomorphicform.py
示例10: __init__
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
开发者ID:mcognetta,项目名称:sage,代码行数:17,代码来源:torsion_point.py
示例11: __init__
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)
开发者ID:saraedum,项目名称:OMS,代码行数:19,代码来源:ocmodule.py
示例12: __init__
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)
开发者ID:fredstro,项目名称:psage,代码行数:21,代码来源:monoidpowerseries_lazyelement.py
示例13: __init__
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)
开发者ID:fredstro,项目名称:psage,代码行数:22,代码来源:gradedexpansion_element.py
示例14: __init__
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)
开发者ID:rburing,项目名称:kontsevich_graph_series,代码行数:38,代码来源:kontsevich_graph_sum.py
示例15: __init__
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
开发者ID:ProgVal,项目名称:sage,代码行数:24,代码来源:fgp_element.py
示例16: __init__
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
开发者ID:mmasdeu,项目名称:darmonpoints,代码行数:24,代码来源:ocmodule.py
示例17: __init__
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)
开发者ID:lalitkumarj,项目名称:OMSCategory,代码行数:6,代码来源:modsym.py
注:本文中的sage.structure.element.ModuleElement类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论