Skip to content

Commit

Permalink
ROTG: fix issue with return type of sqrt
Browse files Browse the repository at this point in the history
Kokkos::sqrt(Kokkos::complex<>) returns a Kokkos::complex<> so in
this case we need to take the module of that since we want a
magnitude_type.
  • Loading branch information
lucbv committed Sep 15, 2022
1 parent 3821780 commit 26f062f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/blas/impl/KokkosBlas1_rotg_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ void Rotg_Invoke(Scalar& a, Scalar& b,
} else {
const Scalar scaled_a = Kokkos::abs(a / numerical_scaling);
const Scalar scaled_b = Kokkos::abs(b / numerical_scaling);
mag_type norm = Kokkos::sqrt(scaled_a * scaled_a + scaled_b * scaled_b) *
numerical_scaling;
mag_type norm =
Kokkos::abs(Kokkos::sqrt(scaled_a * scaled_a + scaled_b * scaled_b)) *
numerical_scaling;
Scalar unit_a = a / Kokkos::abs(a);
c = Kokkos::abs(a) / norm;
s = unit_a * Kokkos::conj(b) / norm;
Expand Down
3 changes: 2 additions & 1 deletion unit_test/blas/Test_Blas1_rotg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ void test_rotg_impl(const Scalar a_in, const Scalar b_in) {
// Initialize inputs/outputs
Scalar a = a_in;
Scalar b = b_in;
Scalar c = zero, s = zero;
magnitude_type c = Kokkos::ArithTraits<magnitude_type>::zero();
Scalar s = zero;

KokkosBlas::rotg(a, b, c, s);

Expand Down

0 comments on commit 26f062f

Please sign in to comment.