Skip to content

Conversation

@quantumsteve
Copy link
Collaborator

@quantumsteve quantumsteve commented Nov 14, 2025

Description

Please describe the issue that is addressed (bug, new feature,
documentation, enhancement, etc.). Please also include relevant motivation and
context. List any dependencies that are required for this change.

This is part of #393. CUDA and HIP functions are not implemented.

Proposed changes

Describe how your changes here address the issue and why the proposed changes
should be accepted.

This adds a new member function MatrixHandler::scaleAddI to compute A := c*A+I. The sparsity pattern (row pointers and column indices) are stored in LinAlgWorkspaceCpu and reused by future calculations. On each column one must check if the diagonal element is already nonzero and add 1 or add a new nonzero element to the matrix.

The test verifies that the sum of rows is 1 larger than the sum of the original row scaled by c.

This adds a new member function MatrixHandler::scaleAddB to compute A := c*A+B. The sparsity pattern (row pointers and column indices) are stored in LinAlgWorkspaceCpu and reused by future calculations. On each column one must increment column indices such that the resulting indices and values are sorted.

Checklist

Put an x in the boxes that apply. You can also fill these out after creating
the PR. If you're unsure about any of them, don't hesitate to ask. We're here
to help! This is simply a reminder of what we are going to look for before
merging your code.

  • All tests pass. Code tested on
    • CPU backend
    • CUDA backend
    • HIP backend
  • Code compiles cleanly with flags -Wall -Wpedantic -Wconversion -Wextra.
  • The new code follows Re::Solve style guidelines.
  • There are unit tests for the new code.
  • The new code is documented.
  • The feature branch is rebased with respect to the target branch.
  • I have updated CHANGELOG.md to reflect the changes in this PR. If this is a minor PR that is part of a larger fix already included in the file, state so.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining
why you chose the solution you did and what alternatives you considered, etc.

Doesn't yet reuse sparsity pattern.
Signed-off-by: Steven Hahn <[email protected]>
Signed-off-by: Steven Hahn <[email protected]>
Signed-off-by: Steven Hahn <[email protected]>
Signed-off-by: Steven Hahn <[email protected]>
Signed-off-by: Steven Hahn <[email protected]>
Signed-off-by: Steven Hahn <[email protected]>
Signed-off-by: Steven Hahn <[email protected]>
Signed-off-by: Steven Hahn <[email protected]>
@quantumsteve quantumsteve changed the title 393 matrixhandler functions Implement A := c*A+I method in MatrixHandler Nov 14, 2025
Signed-off-by: Steven Hahn <[email protected]>
@quantumsteve quantumsteve force-pushed the 393_matrixhandler_functions branch from 2e71d14 to fa0c360 Compare November 15, 2025 00:26
@quantumsteve quantumsteve changed the title Implement A := c*A+I method in MatrixHandler Implement A := c*A+I and A := c*A+B methods in MatrixHandler Nov 17, 2025
Signed-off-by: Steven Hahn <[email protected]>
@shakedregev shakedregev marked this pull request as draft November 18, 2025 17:30
quantumsteve and others added 6 commits November 18, 2025 12:40
Signed-off-by: Steven Hahn <[email protected]>
Signed-off-by: Steven Hahn <[email protected]>
Signed-off-by: Steven Hahn <[email protected]>
Signed-off-by: Steven Hahn <[email protected]>
pointers are on host, not device
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.

2 participants