#9648: New feature: ModulesWithBasis allows module_morphism's to a wider class
of
codomains
-------------------------------+--------------------------------------------
Reporter: stumpc5 | Owner: sage-combinat
Type: enhancement | Status: new
Priority: major | Milestone:
Component: combinatorics | Keywords: ModulesWithBasis, module_morphism
Author: Christian Stump | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
-------------------------------+--------------------------------------------
At the moment, module morphisms are only allowed between modules with
bases having the same base ring.
This patch allows a wider class of codomains, namely any parent with a
base ring having a coerce map from the base ring of domain:
{{{
codomain.base_ring().has_coerce_map_from( domain.base_ring() )
}}}
is replaced by
{{{
hasattr( codomain, 'base_ring' ) and
codomain.base_ring().has_coerce_map_from( domain.base_ring() )
}}}
Also, module morphisms are not restricted anymore to having codomains
being modules with basis but rings are allowed as well.
Here are several examples included in the code:
module morphisms from a module with basis to its base ring
{{{
sage: X = CombinatorialFreeModule(QQ,[1,-1])
sage: phi = X.module_morphism( on_basis=lambda i: i,
codomain=QQ )
sage: phi( 2 * X.monomial(1) + 3 * X.monomial(-1) )
-1
}}}
module morphisms from a module with basis to a base extension of its base
ring
{{{
sage: phi = X.module_morphism(on_basis= lambda i: i,
codomain=RR )
sage: phi( 2 * X.monomial(1) + 3 * X.monomial(-1) )
-1.00000000000000
}}}
module morphisms from a module with basis to a module with basis over a
base extension
{{{
sage: R2 = CombinatorialFreeModule(RR,['x','y'])
sage: C = CombinatorialFreeModule(CC,['z'])
sage: x = X.monomial('x')
sage: y = X.monomial('y')
sage: z = Y.monomial('z')
sage: def on_basis( a ):
if a == 'x':
return CC(1) * z
elif a == 'y':
return CC(I) * z
....:
sage: phi = R2.module_morphism( on_basis=on_basis,
codomain=C )
sage: v = 3 * x + 2 * y
3.00000000000000*B['x'] + 2.00000000000000*B['y']
sage: phi(v)
(3.00000000000000+2.00000000000000*I)*B['z']
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9648>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.