Skip to content

Commit

Permalink
refactort code
Browse files Browse the repository at this point in the history
  • Loading branch information
Guglielmo Gagliardi committed Jan 3, 2024
1 parent 93769f4 commit 69e3423
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 16 additions & 0 deletions test/include/dlaf_test/matrix/util_generic_blas_extensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,20 @@ auto getMatrixScal(const T beta) {
using internal::opValFunc;
return std::make_tuple(el_a, res_a);
}

template <class ElementIndex, class T>
auto getMatrixAdd(const T beta) {
using dlaf::test::TypeUtilities;

auto el_a = [](const ElementIndex& index) {
const double i = index.row();
const double k = index.col();
return TypeUtilities<T>::polar(.9 * (i + 1) / (k + .5), 2 * i - k);
};

auto res_a = [beta, el_a](const ElementIndex& index) { return beta * el_a(index); };

using internal::opValFunc;
return std::make_tuple(el_a, res_a);
}
}
3 changes: 1 addition & 2 deletions test/unit/test_blas_tile/test_add.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ void testAdd(const blas::Op op_a, const blas::Op op_b, const SizeType m, const S
const T alpha = TypeUtilities<T>::element(-1.2, .7);
const T beta = TypeUtilities<T>::element(1.1, .4);

auto [el_a, el_b, el_c, res_c] =
getMatrixMatrixMultiplication<TileElementIndex, T>(op_a, op_b, k, alpha, beta);
auto [el_a, el_b, el_c, res_c] = getMatrixAdd<TileElementIndex, T>(op_a, op_b, k, alpha, beta);

auto a = createTile<CT, D>(el_a, size_a, lda);
auto b = createTile<CT, D>(el_b, size_b, ldb);
Expand Down

0 comments on commit 69e3423

Please sign in to comment.