Skip to content

Commit

Permalink
batched - dense: Testing and fixing Serial QR
Browse files Browse the repository at this point in the history
The serial QR algorithms does not have unit-tests and is failing
for non square matrices. See issue #2328.
This first commit fixes the issue with rectangular matrices and
adds a basic test for that use case. Next will work on adding a
test that exercises the interfaces on multiple matrices of different
sizes within a parallel_for. Finally equivalent tests will be added
for the square case as well.
  • Loading branch information
lucbv committed Sep 19, 2024
1 parent 2c4dd7e commit f598101
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions batched/dense/impl/KokkosBatched_QR_FormQ_Serial_Internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ struct SerialQR_FormQ_Internal {
/// B is m x m

// set identity
if (is_Q_zero)
SerialSetInternal::invoke(m, value_type(1), Q, qs0 + qs1);
else
if (is_Q_zero) {
for (int idx = 0; idx < m; ++idx) {
Q[(qs0 + qs1) * idx] = value_type(1);
// SerialSetInternal::invoke(m, value_type(1), Q, qs0 + qs1);
}
} else {
SerialSetIdentityInternal::invoke(m, Q, qs0, qs1);
}

return SerialApplyQ_LeftNoTransForwardInternal ::invoke(m, m, k, A, as0, as1, t, ts, Q, qs0, qs1, w);
return SerialApplyQ_LeftForwardInternal::invoke(m, m, k, A, as0, as1, t, ts, Q, qs0, qs1, w);
}
};

Expand Down
2 changes: 1 addition & 1 deletion batched/dense/impl/KokkosBatched_QR_Serial_Internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct SerialQR_Internal {
A_part2x2.partWithATL(A, m, n, 0, 0);
t_part2x1.partWithAT(t, m, 0);

for (int m_atl = 0; m_atl < m; ++m_atl) {
for (int m_atl = 0; m_atl < Kokkos::min(m, n); ++m_atl) {
// part 2x2 into 3x3
A_part3x3.partWithABR(A_part2x2, 1, 1);
const int m_A22 = m - m_atl - 1;
Expand Down
1 change: 1 addition & 0 deletions batched/dense/unit_test/Test_Batched_Dense.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "Test_Batched_SerialLU.hpp"
#include "Test_Batched_SerialLU_Real.hpp"
#include "Test_Batched_SerialLU_Complex.hpp"
#include "Test_Batched_SerialQR.hpp"
#include "Test_Batched_SerialSolveLU.hpp"
#include "Test_Batched_SerialSolveLU_Real.hpp"
#include "Test_Batched_SerialSolveLU_Complex.hpp"
Expand Down

0 comments on commit f598101

Please sign in to comment.