Skip to content

Commit e013782

Browse files
committed
suggest Matrix
1 parent f30950e commit e013782

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

cpp11armadillotest/DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Authors@R: c(
1212
)
1313
Suggests:
1414
knitr,
15+
Matrix,
1516
rmarkdown,
1617
testthat (>= 3.0.0)
1718
Depends: R(>= 3.5.0)

cpp11armadillotest/tests/testthat/test-sparse-matrices.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
test_that("sparse matrices copy works", {
2+
if (!requireNamespace("Matrix", quietly = TRUE)) {
3+
skip("Matrix package is not available")
4+
}
5+
26
M <- Matrix::Matrix(c(0, 0, 0, 2, 6, 0, -1, 5, 0, 4, 3, 0, 0, 0, 5, 0),
37
nrow = 4, ncol = 4, sparse = TRUE
48
)

inst/include/wrappers/sparse_matrices.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ inline SpMat<T> dblint_matrix_to_SpMat_(const U& x) {
3636
#ifdef _OPENMP
3737
#pragma omp parallel for schedule(static)
3838
#endif
39-
for (const auto& pos : non_zero_positions) {
39+
for (size_t k = 0; k < non_zero_positions.size(); ++k) {
40+
const auto& pos = non_zero_positions[k];
4041
y(pos.first, pos.second) = x(pos.first, pos.second);
4142
}
4243

0 commit comments

Comments
 (0)