diff --git a/core/matrix/csr.cpp b/core/matrix/csr.cpp index aa4903bf1d0..e32427d67de 100644 --- a/core/matrix/csr.cpp +++ b/core/matrix/csr.cpp @@ -670,6 +670,12 @@ transform_reusable(const Csr* input, gko::dim<2> out_size, } +template +Csr::permuting_reuse_info::permuting_reuse_info() + : permuting_reuse_info{nullptr} +{} + + template Csr::permuting_reuse_info::permuting_reuse_info( std::unique_ptr> value_permutation) @@ -681,6 +687,9 @@ template void Csr::permuting_reuse_info::update_values( ptr_param input, ptr_param output) const { + if (!value_permutation) { + GKO_NOT_SUPPORTED(value_permutation); + } input->create_const_value_view()->permute( value_permutation, output->create_value_view(), permute_mode::rows); } diff --git a/core/test/matrix/csr.cpp b/core/test/matrix/csr.cpp index 4bbdc63851a..95beb56d4da 100644 --- a/core/test/matrix/csr.cpp +++ b/core/test/matrix/csr.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors +// SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors // // SPDX-License-Identifier: BSD-3-Clause @@ -8,6 +8,7 @@ #include #include "core/test/utils.hpp" +#include "ginkgo/core/base/exception.hpp" namespace { @@ -419,4 +420,13 @@ TYPED_TEST(Csr, GeneratesCorrectMatrixData) } +TYPED_TEST(Csr, PermutingReuseInfoDefaultUpdateException) +{ + using Mtx = typename TestFixture::Mtx; + typename Mtx::permuting_reuse_info reuse; + + ASSERT_THROW(reuse.update_values(this->mtx, this->mtx), gko::NotSupported); +} + + } // namespace diff --git a/include/ginkgo/core/matrix/csr.hpp b/include/ginkgo/core/matrix/csr.hpp index 7f57066af78..e9b8e650941 100644 --- a/include/ginkgo/core/matrix/csr.hpp +++ b/include/ginkgo/core/matrix/csr.hpp @@ -762,6 +762,9 @@ class Csr : public EnableLinOp>, * values of the matrix into the transformed matrix. */ struct permuting_reuse_info { + /** Creates an empty reuse info. */ + explicit permuting_reuse_info(); + /** Creates a reuse info structure from its value permutation. */ permuting_reuse_info( std::unique_ptr> value_permutation); @@ -805,9 +808,7 @@ class Csr : public EnableLinOp>, * If permute_mode::rows is set, the rows will be permuted. * If permute_mode::columns is set, the columns will be * permuted. - * @return an std::pair consisting of the transposed matrix and the reuse - * info struct that can be used to update values in the transposed - * matrix. + * @return The permuted matrix. */ std::unique_ptr permute( ptr_param> permutation,