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

multiplication specialization for RectDiagonal and DiagonalFill #405

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

Wu-Chenyang
Copy link
Contributor

@Wu-Chenyang Wu-Chenyang commented Feb 16, 2025

This PR implements the multiplication specialization for RectDiagonal and DiagonalFill in accordance to the following table.

| Left \ Right Multiplier | RectDiagonal | RectDiagonalFill | RectDiagonalZeros | RectDiagonalOnes | Diagonal | DiagonalFill | DiagonalZeros | DiagonalOnes | Zeros | Ones | Fill | Mat | Vec | ZerosVec | OnesVec | FillVec | Adjoint/Transpose Vec | Adjoint/Transpose ZerosVec | Adjoint/Transpose OnesVec | Adjoint/Transpose FillVec |
|------------------------|--------------|------------------|-------------------|------------------|-----------|--------------|---------------|--------------|--------|------|------|-----|-----|-----------|----------|----------|---------------------|------------------------|------------------------|------------------------|
| RectDiagonal | RectDiagonal | RectDiagonal | Zeros | RectDiagonal | RectDiagonal | RectDiagonal | Zeros | RectDiagonal | Zeros | Mat | Mat | Mat | Vec | Zeros | Vec | Vec | Mat | Zeros | Mat | Mat |
| RectDiagonalFill | RectDiagonal | RectDiagonal | Zeros | RectDiagonal | RectDiagonal | RectDiagonalFill | Zeros | RectDiagonalFill | Zeros | Mat | Mat | Mat | Vec | Zeros | Vec | Vec | Mat | Zeros | Mat | Mat |
| RectDiagonalZeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros |
| RectDiagonalOnes | RectDiagonal | RectDiagonal | Zeros | RectDiagonal | RectDiagonal | RectDiagonalFill | Zeros | RectDiagonalOnes | Zeros | Mat | Mat | Mat | Vec | Zeros | Vec | Vec | Mat | Zeros | Mat | Mat |
| Diagonal | RectDiagonal | RectDiagonal | Zeros | RectDiagonal | Diagonal | Diagonal | DiagonalZeros | Diagonal | Zeros | Mat | Mat | Mat | Vec | Zeros | Vec | Vec | Mat | Zeros | Mat | Mat |
| DiagonalFill | RectDiagonal | RectDiagonalFill | Zeros | RectDiagonalFill | Diagonal | DiagonalFill | DiagonalZeros | DiagonalFill | Zeros | Fill | Fill | Mat | Vec | Zeros | Fill | Fill | Mat | Zeros | Fill | Fill |
| DiagonalZeros | Zeros | Zeros | Zeros | Zeros | DiagonalZeros | DiagonalZeros | DiagonalZeros | DiagonalZeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros |
| DiagonalOnes | RectDiagonal | RectDiagonalFill | Zeros | RectDiagonalOnes | Diagonal | DiagonalFill | DiagonalZeros | DiagonalOnes | Zeros | Ones | Fill | Mat | Vec | Zeros | Ones | Fill | Mat | Zeros | Ones | Fill |
| Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros |
| Ones | Mat | Mat | Zeros | Mat | Mat | Fill | Zeros | Ones | Zeros | Fill | Fill | Mat | Fill | Zeros | Fill | Fill | Mat | Zeros | Ones | Fill |
| Fill | Mat | Mat | Zeros | Mat | Mat | Fill | Zeros | Fill | Zeros | Fill | Fill | Mat | Fill | Zeros | Fill | Fill | Mat | Zeros | Fill | Fill |
| Mat | Mat | Mat | Zeros | Mat | Mat | Mat | Zeros | Mat | Zeros | Mat | Mat | Mat | Vec | Zeros | Vec | Vec | Mat | Zeros | Mat | Mat |
| Vec | Mat | Mat | Zeros | Mat | Mat | Mat | Zeros | Mat | Zeros | Fill | Fill | Mat | \ | \ | \ | \ | Mat | Zeros | Mat | Mat |
| ZerosVec | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | \ | \ | \ | \ | Zeros | Zeros | Zeros | Zeros |
| OnesVec | Vec | Vec | Zeros | Vec | Vec | Fill | Zeros | Ones | Zeros | Ones | Fill | Mat | \ | \ | \ | \ | Mat | Zeros | Ones | Fill |
| FillVec | Vec | Vec | Zeros | Vec | Vec | Fill | Zeros | Fill | Zeros | Fill | Fill | Mat | \ | \ | \ | \ | Mat | Zeros | Fill | Fill |
| Adjoint/Transpose Vec | Mat | Mat | Zeros | Mat | Mat | Mat | Zeros | Mat | Zeros | Mat | Mat | Mat | Number | Number | Number | Number | \ | \ | \ | \ |
| Adjoint/Transpose ZerosVec | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Zeros | Number | Number | Number | Number | \ | \ | \ | \ |
| Adjoint/Transpose OnesVec | Mat | Mat | Zeros | Mat | Mat | Fill | Zeros | Ones | Zeros | Fill | Fill | Mat | Number | Number | Number | Number | \ | \ | \ | \ |
| Adjoint/Transpose FillVec | Mat | Mat | Zeros | Mat | Mat | Fill | Zeros | Fill | Zeros | Fill | Fill | Mat | Number | Number | Number | Number | \ | \ | \ | \ |

It also implements the scalar multiplication of RectDiagonal mentioned in #107.
Incidentally, it implements some other related operations including:

  • Transpose and Adjoint of RectDiagonal
  • Out products vec * adjoint(vec) and vec * transpose(vec) for AbstractFillVector
  • Multiplication specialization for OneElementMatrix and DiagonalFill

Copy link

codecov bot commented Feb 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.38%. Comparing base (877375f) to head (8c374a1).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #405      +/-   ##
==========================================
- Coverage   99.48%   99.38%   -0.11%     
==========================================
  Files           8        8              
  Lines        1157     1293     +136     
==========================================
+ Hits         1151     1285     +134     
- Misses          6        8       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Wu-Chenyang
Copy link
Contributor Author

There are two possible solutions for resolving the failed integration tests:

  1. Implement methods for the multiplication of DiagonalFill and LayoutMatrix in an extension file
  2. Change the AbstractMatrix at fillalgebra.jl#L644 to Matrix.

Tell me if any of these options is preferred, and I will make the changes.

Besides, the pull request is now ready for review. Please let me know if any of the code is confusing or requires modification.

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.

1 participant