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

Implement all scalar arithmetic methods for gr_mat #2143

Merged
merged 2 commits into from
Jan 9, 2025

Conversation

fredrik-johansson
Copy link
Collaborator

Fixes #2105.

@albinahlback
Copy link
Collaborator

I don't like having add_scalar meaning $a + \mathbb{1} x$, where $x$ is a scalar, and $a$ is a matrix and $\mathbb{1}$ is the identity matrix. Would something along add_scalar_id or something make more sense?

@fredrik-johansson
Copy link
Collaborator Author

fredrik-johansson commented Jan 9, 2025

This is the only definition that makes sense for matrix algebras. Adding or subtracting a constant to all entries of a matrix is a much more rare operation. There is already gr_mat_entrywise_binary_op and gr_mat_entrywise_binary_op_scalar for that though we could add gr_mat_entrywise_add_scalar and gr_mat_entrywise_sub_scalar as well.

@albinahlback
Copy link
Collaborator

Yeah, I'm not saying that the entrywise would make more sense. Scalars could in some regards be viewed as 1x1 matrices, and then of course the dimensions do not match (in general).

To be clear, I'm okay with this naming scheme, but I would prefer something else.

@fredrik-johansson
Copy link
Collaborator Author

A "scalar matrix" is usually defined (https://en.wikipedia.org/wiki/Diagonal_matrix#Scalar_matrix) as a scalar multiple of an identity matrix, not specifically 1x1.

@edgarcosta
Copy link
Member

I think what @fredrik-johansson proposed makes sense.

By definition, an algebra $$A$$comes equipped by multiplication with scalars requires: $$a \cdot x$$, where $$(a \cdot x) \cdot (b \cdot y) = (ab) \cdot (x \cdot y)$$, where $$a$$ are elements of the coefficient ring $$R$$.

In other words, there is a homomorphism $$R \to A$$ given by $$a \mapsto a \cdot 1$$ , and thus when one adds a scalar, that is why we think about $$a \cdot 1$$, as we are thinking about $$R$$ embedded in $$A$$ via the homomorphism.

@fredrik-johansson fredrik-johansson merged commit c9c581c into flintlib:main Jan 9, 2025
12 checks passed
@fredrik-johansson fredrik-johansson deleted the gr_mat_scalar branch January 25, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gr_poly_integral fails for polynomial over matrix ring
3 participants