diff --git a/core/test/base/batch_multi_vector.cpp b/core/test/base/batch_multi_vector.cpp index e63ed883517..43d3a1ddac6 100644 --- a/core/test/base/batch_multi_vector.cpp +++ b/core/test/base/batch_multi_vector.cpp @@ -108,6 +108,14 @@ TYPED_TEST(BatchMultiVector, KnowsItsSizeAndValues) } +TYPED_TEST(BatchMultiVector, CanGetValuesForEntry) +{ + using value_type = typename TestFixture::value_type; + + ASSERT_EQ(this->mtx->get_values_for_entry(1)[0], value_type{1.0}); +} + + TYPED_TEST(BatchMultiVector, CanBeCopied) { auto mtx_copy = gko::BatchMultiVector::create(this->exec); diff --git a/include/ginkgo/core/base/batch_multi_vector.hpp b/include/ginkgo/core/base/batch_multi_vector.hpp index b91c50966a1..f7c8258121f 100644 --- a/include/ginkgo/core/base/batch_multi_vector.hpp +++ b/include/ginkgo/core/base/batch_multi_vector.hpp @@ -170,6 +170,28 @@ class BatchMultiVector */ dim<2> get_common_size() const { return batch_size_.get_common_size(); } + /** + * Returns a pointer to the array of values of the multi-vector + * + * @return the pointer to the array of values + */ + value_type* get_values(size_type batch_id = 0) noexcept + { + return values_.get_data(); + } + + /** + * @copydoc get_values(size_type) + * + * @note This is the constant version of the function, which can be + * significantly more memory efficient than the non-constant version, + * so always prefer this version. + */ + const value_type* get_const_values() const noexcept + { + return values_.get_const_data(); + } + /** * Returns a pointer to the array of values of the multi-vector for a * specific batch entry. @@ -178,7 +200,7 @@ class BatchMultiVector * * @return the pointer to the array of values */ - value_type* get_values(size_type batch_id = 0) noexcept + value_type* get_values_for_entry(size_type batch_id) noexcept { GKO_ASSERT(batch_id < this->get_num_batch_entries()); return values_.get_data() + @@ -186,13 +208,14 @@ class BatchMultiVector } /** - * @copydoc get_values(size_type) + * @copydoc get_values_at_entry(size_type) * * @note This is the constant version of the function, which can be * significantly more memory efficient than the non-constant version, * so always prefer this version. */ - const value_type* get_const_values(size_type batch_id = 0) const noexcept + const value_type* get_const_values_for_entry( + size_type batch_id) const noexcept { GKO_ASSERT(batch_id < this->get_num_batch_entries()); return values_.get_const_data() + diff --git a/test/test_install/test_install.cpp b/test/test_install/test_install.cpp index 2467e99f62b..ed62e3ca3d3 100644 --- a/test/test_install/test_install.cpp +++ b/test/test_install/test_install.cpp @@ -213,8 +213,7 @@ int main() // core/base/batch_dim.hpp { using type1 = int; - auto common_size = gko::dim<2>{4, 2}; - auto test = gko::batch_dim<2, type1>{2, common_size}; + auto test = gko::batch_dim<2, type1>{}; } // core/base/batch_multi_vector.hpp