From 23da0758d163e0ce5fd58cd8bcbe06321c37c5d2 Mon Sep 17 00:00:00 2001 From: Maanas Arora Date: Mon, 5 Jan 2026 10:21:38 -0500 Subject: [PATCH] Bug: update `MatrixHandler::addConst` return type to int (#402) * Bug: update MatrixHandler::addConst return type to int * Doc: Update CHANGELOG.md --- CHANGELOG.md | 2 ++ resolve/matrix/MatrixHandler.cpp | 7 ++++--- resolve/matrix/MatrixHandler.hpp | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35747bd92..b02211f9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,3 +63,5 @@ It is seamless from the user perspective and fixed many bugs. 14. Various Spack updates. 15. Added examples/sysGmres.cpp to demonstrate how to use SystemSolver with GMRES. + +16. Updated MatrixHandler::addConst to return integer error codes instead of void. diff --git a/resolve/matrix/MatrixHandler.cpp b/resolve/matrix/MatrixHandler.cpp index 1d570af85..aec483a18 100644 --- a/resolve/matrix/MatrixHandler.cpp +++ b/resolve/matrix/MatrixHandler.cpp @@ -337,18 +337,19 @@ namespace ReSolve * @param[in] memspace - Device where the operation is computed * @return 0 if successful, 1 otherwise */ - void MatrixHandler::addConst(matrix::Sparse* A, real_type alpha, memory::MemorySpace memspace) + int MatrixHandler::addConst(matrix::Sparse* A, real_type alpha, memory::MemorySpace memspace) { using namespace ReSolve::memory; switch (memspace) { case HOST: - cpuImpl_->addConst(A, alpha); + return cpuImpl_->addConst(A, alpha); break; case DEVICE: - devImpl_->addConst(A, alpha); + return devImpl_->addConst(A, alpha); break; } + return 1; } /** diff --git a/resolve/matrix/MatrixHandler.hpp b/resolve/matrix/MatrixHandler.hpp index 6b6785aba..8be297304 100644 --- a/resolve/matrix/MatrixHandler.hpp +++ b/resolve/matrix/MatrixHandler.hpp @@ -60,7 +60,7 @@ namespace ReSolve int rightScale(matrix::Csr* A, vector_type* diag, memory::MemorySpace memspace); - void addConst(matrix::Sparse* A, real_type alpha, memory::MemorySpace memspace); + int addConst(matrix::Sparse* A, real_type alpha, memory::MemorySpace memspace); /// Should compute vec_result := alpha*A*vec_x + beta*vec_result, but at least on cpu alpha and beta are flipped int matvec(matrix::Sparse* A,