Skip to content

Conversation

@jowezarek
Copy link
Contributor

@jowezarek jowezarek commented Oct 30, 2025

We add a diagonal(self, inverse=False, sqrt=False, out=None) method to the class KroneckerStencilMatrix.
Additionally, we fix the diagonal method of StencilDiagonalMatrix, both making it run in general, and also allowing for the kwarg sqrt which had been missing until now.

This method comes in handy for the computation of the yet to be implemented LST preconditioners.
For the computation of these, we compute 1D mass matrices which are the building blocks of 2D or 3D logical mass matrices. Additionally, we compute the diagonal of said 2D or 3D logical mass matrix.
Thus, instead of having to assemble the entire 2D or 3D mass matrix, we can build them as KroneckerStencilMatrices, which is much cheaper, and then obtain the diagonal.

This feature reduces the runtime of a yet to be implemented LST preconditioner test from 2 minutes down to 20 seconds.

A very fast test for this new method is included in this PR.

@jowezarek jowezarek marked this pull request as ready for review October 30, 2025 16:16
@jowezarek jowezarek requested a review from yguclu October 30, 2025 16:17
@jowezarek jowezarek marked this pull request as draft October 30, 2025 16:18
@jowezarek jowezarek removed the request for review from yguclu October 30, 2025 16:19
@codacy-production
Copy link

codacy-production bot commented Oct 30, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-0.01% 59.38%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (b459cb9) 31868 19715 61.86%
Head commit (9b6e6a3) 63782 (+31914) 39452 (+19737) 61.85% (-0.01%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#537) 32 19 59.38%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@jowezarek jowezarek mentioned this pull request Oct 31, 2025
@yguclu yguclu added the Next Release Must be in next release label Nov 12, 2025
@jowezarek jowezarek marked this pull request as ready for review November 24, 2025 10:53
@jowezarek jowezarek requested a review from yguclu November 24, 2025 10:53
Copy link
Member

@yguclu yguclu left a comment

Choose a reason for hiding this comment

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

Good job @jowezarek!

I have just a couple of comments

Copy link
Member

@yguclu yguclu left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@yguclu yguclu merged commit dc93a31 into devel Nov 25, 2025
10 checks passed
@yguclu yguclu deleted the kron_diagonal branch November 25, 2025 06:12
@yguclu yguclu linked an issue Dec 10, 2025 that may be closed by this pull request
campospinto pushed a commit that referenced this pull request Dec 12, 2025
We add a `diagonal(self, inverse=False, sqrt=False, out=None)` method to
the class `KroneckerStencilMatrix`.
Additionally, we fix the `diagonal` method of `StencilDiagonalMatrix`,
both making it run in general, and also allowing for the kwarg `sqrt`
which had been missing until now.

This method comes in handy for the computation of the yet to be
implemented LST preconditioners.
For the computation of these, we compute 1D mass matrices which are the
building blocks of 2D or 3D logical mass matrices. Additionally, we
compute the diagonal of said 2D or 3D logical mass matrix.
Thus, instead of having to assemble the entire 2D or 3D mass matrix, we
can build them as `KroneckerStencilMatrices`, which is much cheaper, and
then obtain the diagonal.

This feature reduces the runtime of a yet to be implemented LST
preconditioner test from 2 minutes down to 20 seconds.

A very fast test for this new method is included in this PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Next Release Must be in next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add diagonal property to KroneckerStencilMatrix

4 participants