本文整理汇总了Python中sage.categories.morphism.Morphism类的典型用法代码示例。如果您正苦于以下问题:Python Morphism类的具体用法?Python Morphism怎么用?Python Morphism使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Morphism类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, parent, im_gens, check=True):
"""
EXAMPLES::
sage: L = LieAlgebra(QQ, 'x,y,z')
sage: Lyn = L.Lyndon()
sage: H = L.Hall()
sage: phi = Lyn.coerce_map_from(H)
We skip the category test because the Homset's element class
does not match this class::
sage: TestSuite(phi).run(skip=['_test_category'])
"""
Morphism.__init__(self, parent)
if not isinstance(im_gens, Sequence_generic):
if not isinstance(im_gens, (tuple, list)):
im_gens = [im_gens]
im_gens = Sequence(im_gens, parent.codomain(), immutable=True)
if check:
if len(im_gens) != len(parent.domain().lie_algebra_generators()):
raise ValueError("number of images must equal number of generators")
# TODO: Implement a (meaningful) _is_valid_homomorphism_()
#if not parent.domain()._is_valid_homomorphism_(parent.codomain(), im_gens):
# raise ValueError("relations do not all (canonically) map to 0 under map determined by images of generators.")
if not im_gens.is_immutable():
import copy
im_gens = copy.copy(im_gens)
im_gens.set_immutable()
self.__im_gens = im_gens
开发者ID:saraedum,项目名称:sage-renamed,代码行数:30,代码来源:morphism.py
示例2: __init__
def __init__(self, relations, base_ring_images, images, codomain, reduce = True) :
r"""
INPUT:
- ``relations`` -- An ideal in a polynomial ring.
- ``base_ring_images`` -- A list or sequence of elements of a ring of (equivariant)
monoid power series.
- ``images`` -- A list or sequence of monoid power series.
- ``codomain`` -- An ambient of (equivariant) monoid power series.
- ``reduce`` -- A boolean (default: ``True``); If ``True`` polynomials will
be reduced before the substitution is carried out.
TESTS::
sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *
sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring 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_ring import *
sage: from psage.modform.fourier_expansion_framework.gradedexpansions.gradedexpansion_functor import *
sage: mps = MonoidPowerSeriesRing(QQ, NNMonoid(False))
sage: ev = GradedExpansionEvaluationHomomorphism(PolynomialRing(QQ, ['a', 'b']).ideal(0), Sequence([MonoidPowerSeries(mps, {1 : 1}, mps.monoid().filter(2))]), Sequence([MonoidPowerSeries(mps, {1 : 1, 2 : 3}, mps.monoid().filter(4))]), mps, False)
"""
self.__relations = relations
self.__base_ring_images = base_ring_images
self.__images = images
self.__reduce = reduce
Morphism.__init__(self, relations.ring(), codomain)
self._repr_type_str = "Evaluation homomorphism from %s to %s" % (relations.ring(), codomain)
开发者ID:RalphieBoy,项目名称:psage,代码行数:29,代码来源:gradedexpansion_functor.py
示例3: __init__
def __init__(self, domain, codomain):
"""
The Python constructor
EXAMPLES::
sage: R = QQ['x']['y']['s','t']['X']
sage: p = R.random_element()
sage: from sage.rings.polynomial.flatten import FlatteningMorphism
sage: f = FlatteningMorphism(R)
sage: g = f.section()
sage: g(f(p)) == p
True
::
sage: R = QQ['a','b','x','y']
sage: S = ZZ['a','b']['x','z']
sage: from sage.rings.polynomial.flatten import UnflatteningMorphism
sage: UnflatteningMorphism(R, S)
Traceback (most recent call last):
...
ValueError: rings must have same base ring
::
sage: R = QQ['a','b','x','y']
sage: S = QQ['a','b']['x','z','w']
sage: from sage.rings.polynomial.flatten import UnflatteningMorphism
sage: UnflatteningMorphism(R, S)
Traceback (most recent call last):
...
ValueError: rings must have the same number of variables
"""
if not is_MPolynomialRing(domain):
raise ValueError("domain should be a multivariate polynomial ring")
if not is_PolynomialRing(codomain) and not is_MPolynomialRing(codomain):
raise ValueError("codomain should be a polynomial ring")
ring = codomain
intermediate_rings = []
while is_PolynomialRing(ring) or is_MPolynomialRing(ring):
intermediate_rings.append(ring)
ring = ring.base_ring()
if domain.base_ring() != intermediate_rings[-1].base_ring():
raise ValueError("rings must have same base ring")
if domain.ngens() != sum([R.ngens() for R in intermediate_rings]):
raise ValueError("rings must have the same number of variables")
self._intermediate_rings = intermediate_rings
self._intermediate_rings.reverse()
Morphism.__init__(self, domain, codomain)
self._repr_type_str = 'Unflattening'
开发者ID:saraedum,项目名称:sage-renamed,代码行数:56,代码来源:flatten.py
示例4: __init__
def __init__(self, map, base_ring=None, cohomology=False):
"""
INPUT:
- ``map`` -- the map of simplicial complexes
- ``base_ring`` -- a field (optional, default ``QQ``)
- ``cohomology`` -- boolean (optional, default ``False``). If
``True``, return the induced map in cohomology rather than
homology.
EXAMPLES::
sage: from sage.homology.homology_morphism import InducedHomologyMorphism
sage: K = simplicial_complexes.RandomComplex(8, 3)
sage: H = Hom(K,K)
sage: id = H.identity()
sage: f = InducedHomologyMorphism(id, QQ)
sage: f.to_matrix(0) == 1 and f.to_matrix(1) == 1 and f.to_matrix(2) == 1
True
sage: f = InducedHomologyMorphism(id, ZZ)
Traceback (most recent call last):
...
ValueError: the coefficient ring must be a field
sage: S1 = simplicial_complexes.Sphere(1).barycentric_subdivision()
sage: S1.is_mutable()
True
sage: g = Hom(S1, S1).identity()
sage: h = g.induced_homology_morphism(QQ)
Traceback (most recent call last):
...
ValueError: the domain and codomain complexes must be immutable
sage: S1.set_immutable()
sage: g = Hom(S1, S1).identity()
sage: h = g.induced_homology_morphism(QQ)
"""
if (isinstance(map.domain(), SimplicialComplex)
and (map.domain().is_mutable() or map.codomain().is_mutable())):
raise ValueError('the domain and codomain complexes must be immutable')
if base_ring is None:
base_ring = QQ
if not base_ring.is_field():
raise ValueError('the coefficient ring must be a field')
self._cohomology = cohomology
self._map = map
self._base_ring = base_ring
if cohomology:
domain = map.domain().cohomology_ring(base_ring=base_ring)
codomain = map.codomain().cohomology_ring(base_ring=base_ring)
Morphism.__init__(self, Hom(domain, codomain,
category=GradedAlgebrasWithBasis(base_ring)))
else:
domain = map.domain().homology_with_basis(base_ring=base_ring, cohomology=cohomology)
codomain = map.codomain().homology_with_basis(base_ring=base_ring, cohomology=cohomology)
Morphism.__init__(self, Hom(domain, codomain,
category=GradedModulesWithBasis(base_ring)))
开发者ID:mcognetta,项目名称:sage,代码行数:56,代码来源:homology_morphism.py
示例5: __init__
def __init__(self, parent):
r"""
TESTS::
sage: from sage.rings.valuation.valuation import DiscretePseudoValuation
sage: isinstance(ZZ.valuation(2), DiscretePseudoValuation)
True
"""
Morphism.__init__(self, parent=parent)
开发者ID:saraedum,项目名称:sage-renamed,代码行数:10,代码来源:valuation.py
示例6: __init__
def __init__(self, parent):
"""
Set-theoretic map between matrix groups.
EXAMPLES::
sage: from sage.groups.matrix_gps.morphism import MatrixGroupMap
sage: MatrixGroupMap(ZZ.Hom(ZZ)) # mathematical nonsense
MatrixGroup endomorphism of Integer Ring
"""
Morphism.__init__(self, parent)
开发者ID:BlairArchibald,项目名称:sage,代码行数:11,代码来源:morphism.py
示例7: __init__
def __init__(self, domain):
r"""
EXAMPLES::
sage: G = AdditiveAbelianGroupWrapper(QQbar, [sqrt(QQbar(2)), sqrt(QQbar(3))], [0, 0])
sage: F = QQbar.coerce_map_from(G); F
Generic morphism:
From: Additive abelian group isomorphic to Z + Z embedded in Algebraic Field
To: Algebraic Field
sage: type(F)
<class 'sage.groups.additive_abelian.additive_abelian_wrapper.UnwrappingMorphism'>
"""
Morphism.__init__(self, domain.Hom(domain.universe()))
开发者ID:mcognetta,项目名称:sage,代码行数:13,代码来源:additive_abelian_wrapper.py
示例8: __init__
def __init__(self, domain):
r"""
TESTS::
sage: from sage.modular.pollack_stevens.sigma0 import Sigma0, _Sigma0Embedding
sage: x = _Sigma0Embedding(Sigma0(3))
sage: TestSuite(x).run(skip=['_test_category'])
# TODO: The category test breaks because _Sigma0Embedding is not an instance of
# the element class of its parent (a homset in the category of
# monoids). I have no idea how to fix this.
"""
Morphism.__init__(self, domain.Hom(domain._matrix_space, category=Monoids()))
开发者ID:saraedum,项目名称:sage-renamed,代码行数:13,代码来源:sigma0.py
示例9: __init__
def __init__(self, model, A, check=True):
r"""
See :class:`HyperbolicIsometry` for full documentation.
EXAMPLES::
sage: A = HyperbolicPlane().UHP().get_isometry(matrix(2, [0,1,-1,0]))
sage: TestSuite(A).run(skip="_test_category")
"""
if check:
model.isometry_test(A)
self._matrix = copy(A) # Make a copy of the potentially mutable matrix
self._matrix.set_immutable() # Make it immutable
Morphism.__init__(self, Hom(model, model))
开发者ID:aaditya-thakkar,项目名称:sage,代码行数:14,代码来源:hyperbolic_isometry.py
示例10: __init__
def __init__(self, domain, codomain):
"""
Initialize ``self``.
EXAMPLES::
sage: L = LieAlgebras(QQ).FiniteDimensional().WithBasis().example()
sage: f = L.lift
We skip the category test since this is currently not an element of
a homspace::
sage: TestSuite(f).run(skip="_test_category")
"""
Morphism.__init__(self, Hom(domain, codomain))
开发者ID:saraedum,项目名称:sage-renamed,代码行数:15,代码来源:lie_algebras.py
示例11: __init__
def __init__(self, domain, codomain) :
"""
INPUT:
- ``domain`` -- A ring; The base ring.
- ``codomain`` -- A ring; The ring of monoid power series.
TESTS::
sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_functor import MonoidPowerSeriesFunctor, MonoidPowerSeriesBaseRingInjection
sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import NNMonoid
sage: mps = MonoidPowerSeriesFunctor(NNMonoid(False))(ZZ)
sage: binj = MonoidPowerSeriesBaseRingInjection(ZZ, mps)
"""
Morphism.__init__(self, domain, codomain)
self._repr_type_str = "MonoidPowerSeries base injection"
开发者ID:Alwnikrotikz,项目名称:purplesage,代码行数:15,代码来源:monoidpowerseries_functor.py
示例12: __init__
def __init__(self, parent, phi, check=True):
"""
A morphism between finitely generated modules over a PID.
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; Q
Finitely generated module V/W over Integer Ring with invariants (4, 12)
sage: phi = Q.hom([Q.0+3*Q.1, -Q.1]); phi
Morphism from module over Integer Ring with invariants (4, 12) to module with invariants (4, 12) that sends the generators to [(1, 3), (0, 11)]
sage: phi(Q.0) == Q.0 + 3*Q.1
True
sage: phi(Q.1) == -Q.1
True
For full documentation, see :class:`FGP_Morphism`.
"""
Morphism.__init__(self, parent)
M = parent.domain()
N = parent.codomain()
if isinstance(phi, FGP_Morphism):
if check:
if phi.parent() != parent:
raise TypeError
phi = phi._phi
check = False # no need
# input: phi is a morphism from MO = M.optimized().V() to N.V()
# that sends MO.W() to N.W()
if check:
if not is_Morphism(phi) and M == N:
A = M.optimized()[0].V()
B = N.V()
s = M.base_ring()(phi) * B.coordinate_module(A).basis_matrix()
phi = A.Hom(B)(s)
MO, _ = M.optimized()
if phi.domain() != MO.V():
raise ValueError("domain of phi must be the covering module for the optimized covering module of the domain")
if phi.codomain() != N.V():
raise ValueError("codomain of phi must be the covering module the codomain.")
# check that MO.W() gets sent into N.W()
# todo (optimize): this is slow:
for x in MO.W().basis():
if phi(x) not in N.W():
raise ValueError("phi must send optimized submodule of M.W() into N.W()")
self._phi = phi
开发者ID:saraedum,项目名称:sage-renamed,代码行数:48,代码来源:fgp_morphism.py
示例13: __init__
def __init__(self, UCF):
r"""
INPUT:
- ``UCF`` -- a universal cyclotomic field
TESTS::
sage: UCF = UniversalCyclotomicField()
sage: UCF.coerce_embedding()
Generic morphism:
From: Universal Cyclotomic Field
To: Algebraic Field
"""
from sage.rings.qqbar import QQbar
Morphism.__init__(self, UCF, QQbar)
开发者ID:aaditya-thakkar,项目名称:sage,代码行数:16,代码来源:universal_cyclotomic_field.py
示例14: __init__
def __init__(self, domain, codomain):
"""
Construct the morphism
TESTS::
sage: Z4 = AbelianGroupWithValues([I], [4])
sage: from sage.groups.abelian_gps.values import AbelianGroupWithValuesEmbedding
sage: AbelianGroupWithValuesEmbedding(Z4, Z4.values_group())
Generic morphism:
From: Multiplicative Abelian group isomorphic to C4
To: Symbolic Ring
"""
assert domain.values_group() is codomain
from sage.categories.homset import Hom
Morphism.__init__(self, Hom(domain, codomain))
开发者ID:biasse,项目名称:sage,代码行数:16,代码来源:values.py
示例15: __init__
def __init__(self, E, kernel):
if not is_EdwardsCurve(E):
raise TypeError("E parameter must be an EdwardsCurve.")
if not isinstance(kernel, type([1,1])) and kernel in E :
# a single point was given, we put it in a list
# the first condition assures that [1,1] is treated as x+1
kernel = [E(kernel)]
if isinstance(kernel, list):
for P in kernel:
if P not in E:
raise ValueError("The generators of the kernel of the isogeny must first lie on the EdwardsCurve")
self.__E1 = E #domain curve
self.__E2 = None #codomain curve; not yet found
self.__degree = None
self.__base_field = E.base_ring()
self.__kernel_gens = kernel
self.__kernel_list = None
self.__degree = None
self.__poly_ring = PolynomialRing(self.__base_field, ['x','y'])
self.__x_var = self.__poly_ring('x')
self.__y_var = self.__poly_ring('y')
# to determine the codomain, and the x and y rational maps
self.__initialize_kernel_list()
self.__compute_B()
self.__compute_E2()
self.__initialize_rational_maps()
self._domain = self.__E1
self._codomain = self.__E2
# sets up the parent
parent = homset.Hom(self.__E1(0).parent(), self.__E2(0).parent())
Morphism.__init__(self, parent)
开发者ID:adarshsaraf123,项目名称:Dissertation,代码行数:40,代码来源:edwards_curve.py
示例16: __init__
def __init__(self,f,X,Y):
"""
Input is a dictionary ``f``, the domain ``X``, and the codomain ``Y``.
One can define the dictionary on the vertices of `X`.
EXAMPLES::
sage: S = SimplicialComplex([[0,1],[2],[3,4],[5]], is_mutable=False)
sage: H = Hom(S,S)
sage: f = {0:0,1:1,2:2,3:3,4:4,5:5}
sage: g = {0:0,1:1,2:0,3:3,4:4,5:0}
sage: x = H(f)
sage: y = H(g)
sage: x == y
False
sage: x.image()
Simplicial complex with vertex set (0, 1, 2, 3, 4, 5) and facets {(3, 4), (5,), (2,), (0, 1)}
sage: y.image()
Simplicial complex with vertex set (0, 1, 3, 4) and facets {(3, 4), (0, 1)}
sage: x.image() == y.image()
False
"""
if not isinstance(X,SimplicialComplex) or not isinstance(Y,SimplicialComplex):
raise ValueError("X and Y must be SimplicialComplexes")
if not set(f.keys()) == set(X._vertex_set):
raise ValueError("f must be a dictionary from the vertex set of X to single values in the vertex set of Y")
dim = X.dimension()
Y_faces = Y.faces()
for k in range(dim+1):
for i in X.faces()[k]:
tup = i.tuple()
fi = []
for j in tup:
fi.append(f[j])
v = Simplex(set(fi))
if not v in Y_faces[v.dimension()]:
raise ValueError("f must be a dictionary from the vertices of X to the vertices of Y")
self._vertex_dictionary = f
Morphism.__init__(self, Hom(X,Y,SimplicialComplexes()))
开发者ID:drupel,项目名称:sage,代码行数:40,代码来源:simplicial_complex_morphism.py
示例17: _repr_
def _repr_(self):
r"""
Return string representation of this morphism.
EXAMPLES::
sage: t = J0(11).hecke_operator(2)
sage: sage.modular.abvar.morphism.Morphism_abstract._repr_(t)
'Abelian variety endomorphism of Abelian variety J0(11) of dimension 1'
sage: J0(42).projection(J0(42)[0])._repr_()
'Abelian variety morphism:\n From: Abelian variety J0(42) of dimension 5\n To: Simple abelian subvariety 14a(1,42) of dimension 1 of J0(42)'
"""
return base_Morphism._repr_(self)
开发者ID:drupel,项目名称:sage,代码行数:13,代码来源:morphism.py
示例18: __repr__
def __repr__(self):
r"""
Return the string representation of this WeierstrassIsomorphism.
OUTPUT:
(string) The underlying morphism, together with an extra line
showing the `(u,r,s,t)` parameters.
EXAMPLES::
sage: E1 = EllipticCurve('5077')
sage: E2 = E1.change_weierstrass_model([2,3,4,5])
sage: E1.isomorphism_to(E2)
Generic morphism:
From: Abelian group of points on Elliptic Curve defined by y^2 + y = x^3 - 7*x + 6 over Rational Field
To: Abelian group of points on Elliptic Curve defined by y^2 + 4*x*y + 11/8*y = x^3 - 7/4*x^2 - 3/2*x - 9/32 over Rational Field
Via: (u,r,s,t) = (2, 3, 4, 5)
"""
return Morphism.__repr__(self) + "\n Via: (u,r,s,t) = " + baseWI.__repr__(self)
开发者ID:mcognetta,项目名称:sage,代码行数:20,代码来源:weierstrass_morphism.py
示例19: __init__
def __init__(self, domain, D):
"""
The Python constructor
EXAMPLES::
sage: S.<x,y> = PolynomialRing(QQ)
sage: D = dict({x:1})
sage: from sage.rings.polynomial.flatten import SpecializationMorphism
sage: phi = SpecializationMorphism(S, D); phi
Specialization morphism:
From: Multivariate Polynomial Ring in x, y over Rational Field
To: Univariate Polynomial Ring in y over Rational Field
sage: phi(x^2 + y^2)
y^2 + 1
::
sage: R.<a,b,c> = PolynomialRing(ZZ)
sage: S.<x,y,z> = PolynomialRing(R)
sage: from sage.rings.polynomial.flatten import SpecializationMorphism
sage: xi = SpecializationMorphism(S, {a:1/2})
Traceback (most recent call last):
...
ValueError: values must be in base ring
"""
if not is_PolynomialRing(domain) and not is_MPolynomialRing(domain):
raise ValueError("domain should be a polynomial ring")
phi = FlatteningMorphism(domain)
newD = dict()
for k in D.keys():
newD[phi(k)] = D[k]
self._im_dict = newD
self._flattening_morph = phi
base = phi.codomain().base_ring()
if not all([c in base for c in D.values()]):
raise ValueError("values must be in base ring")
#make unflattened codomain
old_vars = []
ring = domain
while is_PolynomialRing(ring) or is_MPolynomialRing(ring):
old_vars.append([ring.gens(), is_MPolynomialRing(ring)])
ring = ring.base_ring()
new_vars = [[[t for t in v if t not in newD.keys()], b] for v,b in old_vars]
new_vars.reverse()
old_vars.reverse()
R = ring.base_ring()
new_gens=[]
for i in range(len(new_vars)):
if new_vars[i][0] != []:
#check to see if it should be multi or univariate
if not new_vars[i][1] or (len(new_vars[i][0])==1 and len(old_vars[i][0])>1):
R = PolynomialRing(R, new_vars[i][0])
else:
R = PolynomialRing(R, new_vars[i][0], len(new_vars[i][0]))
new_gens.extend(list(R.gens()))
old_gens = [t for v in new_vars for t in v]
#unflattening eval
vals = []
ind = 0
for t in phi.codomain().gens():
if t in newD.keys():
vals.append(newD[t])
else:
vals.append(new_gens[ind])
ind += 1
psi = phi.codomain().hom(vals, R)
self._unflattening_morph = psi
self._repr_type_str = 'Specialization'
Morphism.__init__(self, domain, R)
开发者ID:mcognetta,项目名称:sage,代码行数:76,代码来源:flatten.py
示例20: __init__
def __init__(self, matrices, f, g=None):
r"""
Create a chain homotopy between the given chain maps
from a dictionary of matrices.
EXAMPLES:
If ``g`` is not specified, it is set equal to
`f - (H \partial + \partial H)`. ::
sage: from sage.homology.chain_homotopy import ChainHomotopy
sage: C = ChainComplex({1: matrix(ZZ, 1, 2, (1,0)), 2: matrix(ZZ, 2, 1, (0, 2))}, degree_of_differential=-1)
sage: D = ChainComplex({2: matrix(ZZ, 1, 1, (6,))}, degree_of_differential=-1)
sage: f_d = {1: matrix(ZZ, 1, 2, (0,3)), 2: identity_matrix(ZZ, 1)}
sage: f = Hom(C,D)(f_d)
sage: H_d = {0: identity_matrix(ZZ, 1), 1: matrix(ZZ, 1, 2, (2,2))}
sage: H = ChainHomotopy(H_d, f)
sage: H._g.in_degree(0)
[]
sage: H._g.in_degree(1)
[-13 -9]
sage: H._g.in_degree(2)
[-3]
TESTS:
Try to construct a chain homotopy in which the maps do not
have matching domains and codomains::
sage: g = Hom(C,C)({}) # the zero chain map
sage: H = ChainHomotopy(H_d, f, g)
Traceback (most recent call last):
...
ValueError: the chain maps are not compatible
"""
domain = f.domain()
codomain = f.codomain()
deg = domain.degree_of_differential()
# Check that the chain complexes are compatible. This should
# never arise, because first there should be errors in
# constructing the chain maps. But just in case...
if domain.degree_of_differential() != codomain.degree_of_differential():
raise ValueError('the chain complexes are not compatible')
if g is not None:
# Check that the chain maps are compatible.
if not (domain == g.domain() and codomain ==
g.codomain()):
raise ValueError('the chain maps are not compatible')
# Check that the data define a chain homotopy.
for i in domain.differential():
if i in matrices and i+deg in matrices:
if not (codomain.differential(i-deg) * matrices[i] + matrices[i+deg] * domain.differential(i) == f.in_degree(i) - g.in_degree(i)):
raise ValueError('the data do not define a valid chain homotopy')
elif i in matrices:
if not (codomain.differential(i-deg) * matrices[i] == f.in_degree(i) - g.in_degree(i)):
raise ValueError('the data do not define a valid chain homotopy')
elif i+deg in matrices:
if not (matrices[i+deg] * domain.differential(i) == f.in_degree(i) - g.in_degree(i)):
raise ValueError('the data do not define a valid chain homotopy')
else:
# Define g.
g_data = {}
for i in domain.differential():
if i in matrices and i+deg in matrices:
g_data[i] = f.in_degree(i) - matrices[i+deg] * domain.differential(i) - codomain.differential(i-deg) * matrices[i]
elif i in matrices:
g_data[i] = f.in_degree(i) - codomain.differential(i-deg) * matrices[i]
elif i+deg in matrices:
g_data[i] = f.in_degree(i) - matrices[i+deg] * domain.differential(i)
g = ChainComplexMorphism(g_data, domain, codomain)
self._matrix_dictionary = {}
for i in matrices:
m = matrices[i]
# Use immutable matrices because they're hashable.
m.set_immutable()
self._matrix_dictionary[i] = m
self._f = f
self._g = g
Morphism.__init__(self, Hom(domain, codomain))
开发者ID:mcognetta,项目名称:sage,代码行数:79,代码来源:chain_homotopy.py
注:本文中的sage.categories.morphism.Morphism类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论