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

Use * to denote matrix multiplication #2232

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dennisYatunin
Copy link
Member

@dennisYatunin dennisYatunin commented Mar 11, 2025

This PR removes the alias const ⋅ = MultiplyColumnwiseBandMatrixField() and allows us to use the standard * symbol to denote matrix multiplication. All internal uses of have been replaced with *, and the exported symbol has been replaced with const ⋅ = *. This export is necessary to avoid breaking ClimaAtmos for now, but it should be removed before the next major release of ClimaCore. (The symbol cannot be marked as deprecated because @deprecate only works for function calls.)

This PR supersedes #2229 and closes #1774.

  • Code follows the style guidelines OR N/A.
  • Unit tests are included OR N/A.
  • Code is exercised in an integration test OR N/A.
  • Documentation has been added/updated OR N/A.

@dennisYatunin dennisYatunin force-pushed the dy/matrix_mul_symbol branch 3 times, most recently from f469f2c to 2445aee Compare March 11, 2025 23:37
Copy link
Member

@charleskawczynski charleskawczynski left a comment

Choose a reason for hiding this comment

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

Changing the meaning of \cdot, via an exported symbol seems like it could lead to a lot of confusion.

I prefer that we start with #2229-- you can pick the symbol if you don't like either of my two suggestions. Then, we can deprecate the use of \cstar, or whatever symbol we decide, update ClimaAtmos and all dependencies accordingly.

Frankly, I would suggest that we simply stick to a new symbol altogether, but I'm also fine with eventually overloading things without exporting any symbols.

@dennisYatunin
Copy link
Member Author

@charleskawczynski, are you not also exporting the ⋅ symbol in #2229? I was merely trying to recreate your PR without the introduction of yet another symbol. Regardless, this symbol is only being exported in order to avoid breaking ClimaAtmos until we make a major release of ClimaCore. In the interest of getting this PR merged in, I will revert const ⋅ = * to const ⋅ = MultiplyColumnwiseBandMatrixField() if that seems safer to you.

I am opposed to merging in #2229 as that introduces a new unnecessary symbol. We should stick to * for denoting multiplication, as that is clearly understandable for users of ClimaCore.

@charleskawczynski
Copy link
Member

@charleskawczynski, are you not also exporting the ⋅ symbol in #2229?

#2229 does still export -- it's not changing the user interface. The main purpose of that PR was to be able to use LinearAlgebra.⋅ and MatrixFields.MultiplyColumnwiseBandMatrixField in the same scope.

I was merely trying to recreate your PR without the introduction of yet another symbol. Regardless, this symbol is only being exported in order to avoid breaking ClimaAtmos until we make a major release of ClimaCore.

Yes, but it's changing the meaning of the symbol, which can lead to a lot of confusion.

In the interest of getting this PR merged in, I will revert const ⋅ = * to const ⋅ = MultiplyColumnwiseBandMatrixField() if that seems safer to you.

It does. Can we deprecate MatrixFields.⋅ in this PR?

I am opposed to merging in #2229 as that introduces a new unnecessary symbol. We should stick to * for denoting multiplication, as that is clearly understandable for users of ClimaCore.

That's fair, so long we have a path towards deprecating the old pattern. Why did we use to begin with?

I think the right path here is to deprecate the existing pattern, and then (perhaps slowly) transition to a new pattern. Can we temporarily leave const ⋅ = MultiplyColumnwiseBandMatrixField() to avoid a breaking release, add support for using *, and @deprecate the use of MatrixFields.⋅?

@dennisYatunin
Copy link
Member Author

As we've discussed offline, it is not possible to deprecate the ⋅ symbol because @deprecate only works for function calls. I am currently trying out the ⋅ → * substitution enabled by this branch in CliMA/ClimaAtmos.jl#3693, and I am rerunning this branch's CI with export ⋅ commented out. If both of these work, this should be good to go (though I'll add the export back in until we make a new major release of ClimaCore).

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.

Hard-to-debug error when LinearAlgebra.cdot and MatrixFields.cdot are both imported
2 participants