Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
sage.modules.free_module.element_class: Use Vector_callable_symbolic_…
Browse files Browse the repository at this point in the history
…dense also for whose modules over rings whose base rings are symbolic rings/subrings
  • Loading branch information
Matthias Koeppe committed Jun 14, 2021
1 parent 30ee8d6 commit a1eccc9
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/sage/modules/free_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -7345,6 +7345,21 @@ def element_class(R, is_sparse):
<type 'sage.modules.free_module_element.FreeModuleElement_generic_sparse'>
sage: sage.modules.free_module.element_class(P, is_sparse=False)
<type 'sage.modules.free_module_element.FreeModuleElement_generic_dense'>
Free modules over symbolic rings and rings whose base rings are symbolic rings::
sage: sage.modules.free_module.element_class(SR, is_sparse=False)
<class 'sage.modules.vector_symbolic_dense.Vector_symbolic_dense'>
sage: SR_a_b = SR.subring(accepting_variables=('a', 'b')); SR_a_b
Symbolic Subring accepting the variables a, b
sage: sage.modules.free_module.element_class(SR_a_b, is_sparse=False)
<class 'sage.modules.vector_symbolic_dense.Vector_symbolic_dense'>
sage: SR_const = SR.subring(no_variables=True); SR_const
Symbolic Constants Subring
sage: SR_poly_t = SR_const['t']; SR_poly_t
Univariate Polynomial Ring in t over Symbolic Constants Subring
sage: sage.modules.free_module.element_class(SR_poly_t, is_sparse=False)
<class 'sage.modules.vector_symbolic_dense.Vector_symbolic_dense'>
"""
import sage.modules.vector_real_double_dense
import sage.modules.vector_complex_double_dense
Expand All @@ -7368,12 +7383,14 @@ def element_class(R, is_sparse):
return sage.modules.vector_real_double_dense.Vector_real_double_dense
elif sage.rings.complex_double.is_ComplexDoubleField(R) and not is_sparse:
return sage.modules.vector_complex_double_dense.Vector_complex_double_dense
elif sage.symbolic.ring.is_SymbolicExpressionRing(R) and not is_sparse:
import sage.modules.vector_symbolic_dense
return sage.modules.vector_symbolic_dense.Vector_symbolic_dense
elif sage.symbolic.callable.is_CallableSymbolicExpressionRing(R) and not is_sparse:
import sage.modules.vector_callable_symbolic_dense
return sage.modules.vector_callable_symbolic_dense.Vector_callable_symbolic_dense
elif ((sage.symbolic.ring.is_SymbolicExpressionRing(R)
or isinstance(R.base_ring(), sage.symbolic.ring.SymbolicRing))
and not is_sparse):
import sage.modules.vector_symbolic_dense
return sage.modules.vector_symbolic_dense.Vector_symbolic_dense
else:
if is_sparse:
return free_module_element.FreeModuleElement_generic_sparse
Expand Down

0 comments on commit a1eccc9

Please sign in to comment.