sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.41k stars 474 forks source link

CombinatorialFreeModule.is_ambient, add element methods `items` and `nonzero_positions` #34511

Open mkoeppe opened 2 years ago

mkoeppe commented 2 years ago

FreeModule (from sage.modules) has a method is_ambient for distinguishing ambient modules from submodules.

We make this method available for CombinatorialFreeModule too via ModulesWithBasis.

Add a method items, with the same semantics as for sparse vectors from sage.modules, and matrices and tensor components after #29619. If self is a submodule, they refer to the ambient module (see #34455). Likewise nonzero_positions, which gives the indices only.

For ambient modules, dict, items, and monomial_coefficients give the same result, and support and nonzero_positions are the same. We enforce this with a _test_... method.

CC: @tscrim

Component: linear algebra

Issue created by migration from https://trac.sagemath.org/ticket/34511

mkoeppe commented 2 years ago

Description changed:

--- 
+++ 
@@ -2,3 +2,4 @@

 We make this method available for `CombinatorialFreeModule` too via `ModulesWithBasis`.

+For ambient modules, `dict` and `monomial_coefficients` give the same result. We enforce this with a `_test_...` method.
mkoeppe commented 2 years ago

Description changed:

--- 
+++ 
@@ -2,4 +2,4 @@

 We make this method available for `CombinatorialFreeModule` too via `ModulesWithBasis`.

-For ambient modules, `dict` and `monomial_coefficients` give the same result. We enforce this with a `_test_...` method.
+For ambient modules, `dict`, `items`, and `monomial_coefficients` give the same result. We enforce this with a `_test_...` method.
mkoeppe commented 2 years ago

Description changed:

--- 
+++ 
@@ -2,4 +2,6 @@

 We make this method available for `CombinatorialFreeModule` too via `ModulesWithBasis`.

+Add a method `items`, with the same semantics as for sparse vectors from `sage.modules`, and matrices and tensor components after #29619. If `self` is a submodule, they refer to the ambient module (see #34455).
+
 For ambient modules, `dict`, `items`, and `monomial_coefficients` give the same result. We enforce this with a `_test_...` method.
mkoeppe commented 2 years ago

Description changed:

--- 
+++ 
@@ -3,5 +3,7 @@
 We make this method available for `CombinatorialFreeModule` too via `ModulesWithBasis`.

 Add a method `items`, with the same semantics as for sparse vectors from `sage.modules`, and matrices and tensor components after #29619. If `self` is a submodule, they refer to the ambient module (see #34455).
+Likewise `nonzero_positions`, which gives the indices only.

-For ambient modules, `dict`, `items`, and `monomial_coefficients` give the same result. We enforce this with a `_test_...` method.
+For ambient modules, `dict`, `items`, and `monomial_coefficients` give the same result, and `support` and `nonzero_positions` are the same. We enforce this with a `_test_...` method.
+
mkoeppe commented 2 years ago

Branch: u/mkoeppe/combinatorialfreemodule_is_ambientadd_element_methodsitemsandnonzeropositions

mkoeppe commented 7 months ago

Removed branch from issue description; replaced by PR #37524.