Skip to content

Commit ecb1323

Browse files
author
Alexander Strack
committed
Reformulate index computation and remove conversion warnings
1 parent 26274e1 commit ecb1323

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

include/plssvm/backends/HPX/kernel/cg_explicit/kernel_matrix_assembly.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ void device_kernel_assembly(const std::vector<real_type> &q, std::vector<real_ty
6161

6262
::hpx::for_each(::hpx::execution::par_unseq, range.begin(), range.end(), [&](const std::size_t idx) {
6363
// calculate the indices used in the current thread
64-
const std::size_t col = static_cast<std::size_t>(0.5 * (2 * blocked_dept + 1 - std::sqrt(4 * blocked_dept * blocked_dept + 4 * blocked_dept - 8 * idx + 1)));
65-
const std::size_t row = static_cast<std::size_t>(idx - (col * blocked_dept - 0.5 * col * col - 0.5 * col));
64+
const std::size_t col = blocked_dept + static_cast<std::size_t>(0.5 - 0.5 * std::sqrt(4 * (blocked_dept * blocked_dept + blocked_dept) - 8 * idx + 1));
65+
const std::size_t row = static_cast<std::size_t>(0.5 * static_cast<double>(2 * (idx - col * blocked_dept) + col * col + col));
6666

6767
const std::size_t row_idx = row * INTERNAL_BLOCK_SIZE_uz;
6868
const std::size_t col_idx = col * INTERNAL_BLOCK_SIZE_uz;

include/plssvm/backends/HPX/kernel/cg_implicit/kernel_matrix_assembly_blas.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ inline void device_kernel_assembly_symm(const real_type alpha, const std::vector
7575

7676
::hpx::for_each(::hpx::execution::par_unseq, range.begin(), range.end(), [&](const std::size_t idx) {
7777
// calculate the indices used in the current thread
78-
const std::size_t col = static_cast<std::size_t>(0.5 * (2 * blocked_dept + 1 - std::sqrt(4 * blocked_dept * blocked_dept + 4 * blocked_dept - 8 * idx + 1)));
79-
const std::size_t row = static_cast<std::size_t>(idx - (col * blocked_dept - 0.5 * col * col - 0.5 * col));
78+
const std::size_t col = blocked_dept + static_cast<std::size_t>(0.5 - 0.5 * std::sqrt(4 * (blocked_dept * blocked_dept + blocked_dept) - 8 * idx + 1));
79+
const std::size_t row = static_cast<std::size_t>(0.5 * static_cast<double>(2 * (idx - col * blocked_dept) + col * col + col));
8080

8181
const std::size_t row_idx = row * INTERNAL_BLOCK_SIZE_uz;
8282
const std::size_t col_idx = col * INTERNAL_BLOCK_SIZE_uz;

0 commit comments

Comments
 (0)