sagemath / sage

Main repository of SageMath. Now open for Issues and Pull Requests.
https://www.sagemath.org
Other
1.08k stars 394 forks source link

`ModulesWithBasis.MorphismMethods`: Add method for matrix of finite-dimensional restriction/projection, move more `MatrixMorphism` methods to category #37879

Open mkoeppe opened 2 weeks ago

mkoeppe commented 2 weeks ago

We extend the technique of "support orders" for infinite-dimensional free modules to their morphisms. The new helper method _matrix_side_bases_orders constructs a matrix suitable for throwing some linear algebra on the modules. (This goes in a similar direction as https://github.com/sagemath/sage/issues/34487.)

                sage: X = CombinatorialFreeModule(QQ, ZZ); x = X.basis()
                sage: def on_basis(i):
                ....:     return X.monomial(i+1) - X.monomial(i+2)
                sage: phi = X.module_morphism(on_basis=on_basis, codomain=X)
                sage: phi._matrix_side_bases_orders()
                Traceback (most recent call last):
                ...
                ValueError: domain or codomain are not finite-dimensional;
                use row_order or column_order to obtain the matrix
                of a finite-dimensional restriction or projection
                sage: phi._matrix_side_bases_orders(row_order=range(5),
                ....:                               column_order=range(4))
                ( [ 0  0  0  0]
                  [ 1  0  0  0]
                  [-1  1  0  0]
                  [ 0 -1  1  0]
                  [ 0  0 -1  1], 'left',
                  Lazy family (Term map from Integer Ring to Free module generated by
                               Integer Ring over Rational Field(i))_{i in Integer Ring},
                  Lazy family (Term map from Integer Ring to Free module generated by
                               Integer Ring over Rational Field(i))_{i in Integer Ring},
                  range(0, 5), range(0, 4) )

As an immediate application of this method, we are able to move some methods (is_injective, is_surjective, is_bijective, nullity, rank) for the finite-dimensional case from MatrixMorphism to the category because we are sidestepping an issue of the existing matrix method:

:memo: Checklist

:hourglass: Dependencies

github-actions[bot] commented 2 weeks ago

Documentation preview for this PR (built with commit 7ceee2eded1dd3f692b34f028ba898eeafa14721; changes) is ready! :tada: This preview will update shortly after each push to this PR.

tscrim commented 2 weeks ago

This can only be done reliably when the domain is a finite dimensional module, otherwise you run into the obvious problem with infinite matrices. Likewise dense_coefficient_list() should be for elements in that category as well (unless you want to have them be arbitrary-but-finite lists of coefficients reflecting the basis order).

mkoeppe commented 2 weeks ago

The idea here is that in the infinite-dimensional case, order will be a required argument (a finite sequence)

mkoeppe commented 2 weeks ago

dense_coefficient_list is generalized here from the existing method for the finite dimensional case.