Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MatrixSpace: Support constructing Hom(CombinatorialFreeModule) #37514

Merged
merged 12 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions src/sage/matrix/args.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -326,21 +326,27 @@ cdef class MatrixArgs:

sage: from sage.matrix.args import MatrixArgs
sage: MatrixArgs().finalized()
<MatrixArgs for Full MatrixSpace of 0 by 0 dense matrices over Integer Ring; typ=ZERO; entries=None>
<MatrixArgs for Full MatrixSpace of 0 by 0 dense matrices over
Integer Ring; typ=ZERO; entries=None>
sage: MatrixArgs(1).finalized()
<MatrixArgs for Full MatrixSpace of 1 by 1 dense matrices over Integer Ring; typ=ZERO; entries=None>
<MatrixArgs for Full MatrixSpace of 1 by 1 dense matrices over
Integer Ring; typ=ZERO; entries=None>
sage: MatrixArgs(1, 1, 3).finalized()
<MatrixArgs for Full MatrixSpace of 1 by 1 dense matrices over Integer Ring; typ=SCALAR; entries=3>
<MatrixArgs for Full MatrixSpace of 1 by 1 dense matrices over
Integer Ring; typ=SCALAR; entries=3>
sage: MatrixArgs(1, 1, 1, 1).finalized()
Traceback (most recent call last):
...
TypeError: too many arguments in matrix constructor
sage: MatrixArgs(3, nrows=1, ncols=1).finalized()
<MatrixArgs for Full MatrixSpace of 1 by 1 dense matrices over Integer Ring; typ=SCALAR; entries=3>
<MatrixArgs for Full MatrixSpace of 1 by 1 dense matrices over
Integer Ring; typ=SCALAR; entries=3>
sage: MatrixArgs(3, nrows=1).finalized()
<MatrixArgs for Full MatrixSpace of 1 by 1 dense matrices over Integer Ring; typ=SCALAR; entries=3>
<MatrixArgs for Full MatrixSpace of 1 by 1 dense matrices over
Integer Ring; typ=SCALAR; entries=3>
sage: MatrixArgs(3, ncols=1).finalized()
<MatrixArgs for Full MatrixSpace of 1 by 1 dense matrices over Integer Ring; typ=SCALAR; entries=3>
<MatrixArgs for Full MatrixSpace of 1 by 1 dense matrices over
Integer Ring; typ=SCALAR; entries=3>
"""
if "ring" in kwds.keys():
deprecation_cython(issue_number=33380, message="ring is deprecated (keyword will be removed in the future). Use base_ring instead", stacklevel=3)
Expand Down Expand Up @@ -646,8 +652,8 @@ cdef class MatrixArgs:

INPUT:

- ``convert`` -- if True, the matrix is guaranteed to have
the correct parent matrix space. If False, the input matrix
- ``convert`` -- if ``True``, the matrix is guaranteed to have
the correct parent matrix space. If ``False``, the input matrix
may be returned even if it lies in the wrong space.

.. NOTE::
Expand Down Expand Up @@ -737,7 +743,7 @@ cdef class MatrixArgs:

INPUT:

- ``convert`` -- If True, the entries are converted to the base
- ``convert`` -- If ``True``, the entries are converted to the base
ring. Otherwise, the entries are returned as given.

.. NOTE::
Expand Down Expand Up @@ -797,11 +803,12 @@ cdef class MatrixArgs:

cpdef dict dict(self, bint convert=True):
"""
Return the entries of the matrix as a dict. The keys of this
dict are the non-zero positions ``(i,j)``. The corresponding
value is the entry at that position. Zero values are skipped.
Return the entries of the matrix as a :class:`dict`.

If ``convert`` is True, the entries are converted to the base
The keys of this :class:`dict` are the non-zero positions ``(i,j)``. The
corresponding value is the entry at that position. Zero values are skipped.

If ``convert`` is ``True``, the entries are converted to the base
ring. Otherwise, the entries are returned as given.

EXAMPLES::
Expand Down
22 changes: 11 additions & 11 deletions src/sage/matrix/constructor.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def matrix(*args, **kwds):

INPUT:

The matrix command takes the entries of a matrix, optionally
The :func:`matrix` command takes the entries of a matrix, optionally
preceded by a ring and the dimensions of the matrix, and returns a
matrix.

Expand All @@ -50,11 +50,11 @@ def matrix(*args, **kwds):
columns. You can create a matrix of zeros by passing an empty list
or the integer zero for the entries. To construct a multiple of
the identity (`cI`), you can specify square dimensions and pass in
`c`. Calling matrix() with a Sage object may return something that
makes sense. Calling matrix() with a NumPy array will convert the
`c`. Calling :func:`matrix` with a Sage object may return something that
makes sense. Calling :func:`matrix` with a NumPy array will convert the
array to a matrix.

All arguments (even the positional) are optional.
All arguments (even the positional ones) are optional.

Positional and keyword arguments:

Expand Down Expand Up @@ -136,37 +136,37 @@ def matrix(*args, **kwds):

::

sage: v1=vector((1,2,3))
sage: v2=vector((4,5,6))
sage: v1 = vector((1,2,3))
sage: v2 = vector((4,5,6))
sage: m = matrix([v1,v2]); m; m.parent()
[1 2 3]
[4 5 6]
Full MatrixSpace of 2 by 3 dense matrices over Integer Ring

::

sage: m = matrix(QQ,2,[1,2,3,4,5,6]); m; m.parent()
sage: m = matrix(QQ, 2, [1,2,3,4,5,6]); m; m.parent()
[1 2 3]
[4 5 6]
Full MatrixSpace of 2 by 3 dense matrices over Rational Field

::

sage: m = matrix(QQ,2,3,[1,2,3,4,5,6]); m; m.parent()
sage: m = matrix(QQ, 2, 3, [1,2,3,4,5,6]); m; m.parent()
[1 2 3]
[4 5 6]
Full MatrixSpace of 2 by 3 dense matrices over Rational Field

::

sage: m = matrix({(0,1): 2, (1,1):2/5}); m; m.parent()
sage: m = matrix({(0,1): 2, (1,1): 2/5}); m; m.parent()
[ 0 2]
[ 0 2/5]
Full MatrixSpace of 2 by 2 sparse matrices over Rational Field

::

sage: m = matrix(QQ,2,3,{(1,1): 2}); m; m.parent()
sage: m = matrix(QQ, 2, 3, {(1,1): 2}); m; m.parent()
[0 0 0]
[0 2 0]
Full MatrixSpace of 2 by 3 sparse matrices over Rational Field
Expand Down Expand Up @@ -235,7 +235,7 @@ def matrix(*args, **kwds):

::

sage: M = Matrix([[1,2,3],[4,5,6],[7,8,9]], immutable=True)
sage: M = Matrix([[1,2,3], [4,5,6], [7,8,9]], immutable=True)
sage: M[0] = [9,9,9]
Traceback (most recent call last):
...
Expand Down
Loading
Loading