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

Commit

Permalink
Create CombinatorialFreeModule if basis keys given
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Jul 28, 2020
1 parent ddaba54 commit 9ee2a48
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/sage/modules/free_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,46 @@ def create_object(self, version, key):
except NotImplementedError:
return FreeModule_ambient(base_ring, rank, sparse=sparse)

FreeModuleFactory_with_standard_basis = FreeModuleFactory("FreeModule")

FreeModule = FreeModuleFactory("FreeModule")
def FreeModule(base_ring, rank_or_basis_keys=None, sparse=False, inner_product_matrix=None, *,
with_basis='standard', rank=None, basis_keys=None, **args):
"""
EXAMPLES::
sage: FreeModule(QQ, ['a', 'b', 'c'])
Free module generated by {'a', 'b', 'c'} over Rational Field
sage: _.category()
Category of finite dimensional vector spaces with basis over Rational Field
sage: FreeModule(QQ, 3, with_basis=None)
3-dimensional vector space over the Rational Field
sage: _.category()
Category of finite dimensional vector spaces over Rational Field
"""
if rank_or_basis_keys is not None:
if rank_or_basis_keys in sage.rings.integer_ring.IntegerRing():
rank = rank_or_basis_keys
else:
basis_keys = rank_or_basis_keys
if not with_basis:
if inner_product_matrix is not None:
raise NotImplementedError
from sage.tensor.modules.finite_rank_free_module import FiniteRankFreeModule
return FiniteRankFreeModule(base_ring, rank, **args)
elif with_basis == 'standard':
if rank is not None:
return FreeModuleFactory_with_standard_basis(base_ring, rank, sparse,
inner_product_matrix, **args)
else:
if inner_product_matrix is not None:
raise NotImplementedError
from sage.combinat.free_module import CombinatorialFreeModule
return CombinatorialFreeModule(base_ring, basis_keys, **args)
else:
raise NotImplementedError

def VectorSpace(K, dimension, sparse=False, inner_product_matrix=None):
"""
Expand Down

0 comments on commit 9ee2a48

Please sign in to comment.