Skip to content

Conversation

@mkoeppe
Copy link
Contributor

@mkoeppe mkoeppe commented Jun 17, 2024

The matrix constructors are designed to accept a scalar as the entries and then construct a diagonal matrix; special case: constructing the zero matrix from 0.

However, when the scalar is a base ring element that happens to have a _matrix_ method, that is tried first, leading to the errors reported in #38221.
Here we change it so that if the base ring (or matrix space) has been specified already and a scalar from that base ring is passed, that takes precedence over using a _matrix_ method. (Coercion is not attempted.)

For the special case of zero_matrix and MatrixSpace.zero_matrix, we now use entries=None, which is the fastest and most robust path in MatrixArgs.entries_type to designate a zero matrix.

Fixes #38221

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

@github-actions
Copy link

Documentation preview for this PR (built with commit 6ed0045; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

Copy link
Collaborator

@tscrim tscrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 20, 2024

Thank you!

@vbraun vbraun merged commit c2372a9 into sagemath:develop Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zero matrix over an algebra

3 participants