Skip to content

Commit 31c2ada

Browse files
authored
Merge pull request #106 from jaganmn/master
Do not throw INT_MAX error when returning vector
2 parents f82ac81 + 639e7f8 commit 31c2ada

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

.codecov.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
coverage:
2-
precision: 1
3-
41
comment: false
2+
coverage:
3+
status:
4+
project:
5+
default:
6+
target: 70% # the (on purpose low) required coverage value
7+
threshold: 2% # the permitted delta in hitting the target
8+
patch:
9+
default:
10+
target: 0% # the (on purpose low) required coverage value
511

6-
ignore:
7-
- "inst/include/Eigen/"
8-
- "inst/include/unsupported/Eigen/"
9-
10-
codecov:
11-
token: 0b726434-b483-4a82-9cfe-e8312f3b3e9b
12+
# layout: "header, diff, tree, changes"
13+
# behavior: default
14+
# require_changes: false # if true: only post the comment if coverage changes
15+
# branches: null
16+
# flags: null
17+
# paths: null

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2022-01-16 Dirk Eddelbuettel <[email protected]>
2+
3+
* .codecov.yml: Added to not trigger PR fail for small additions
4+
5+
2022-01-16 Mikael Jagan <[email protected]>
6+
7+
* inst/include/RcppEigenWrap.h: Refine use plain dense wrap() change
8+
19
2022-01-15 Mikael Jagan <[email protected]>
210

311
* inst/include/RcppEigenWrap.h: Use R_xlen_t for vectors rows + cols

inst/include/RcppEigenWrap.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,21 @@ namespace Rcpp{
8181
// for plain dense objects
8282
template <typename T>
8383
SEXP eigen_wrap_plain_dense( const T& obj, Rcpp::traits::true_type ) {
84+
bool needs_dim = T::ColsAtCompileTime != 1;
85+
R_xlen_t m = obj.rows(), n = obj.cols();
86+
if (needs_dim && (m > INT_MAX || n > INT_MAX)) {
87+
Rcpp::stop("array dimensions cannot exceed INT_MAX");
88+
}
89+
R_xlen_t size = m * n;
8490
typename Eigen::internal::conditional<
8591
T::IsRowMajor,
8692
Eigen::Matrix<typename T::Scalar,
8793
T::RowsAtCompileTime,
8894
T::ColsAtCompileTime>,
8995
const T&>::type objCopy(obj);
90-
R_xlen_t m = obj.rows(), n = obj.cols(), size = m * n;
91-
if (m > INT_MAX || n > INT_MAX) {
92-
Rcpp::stop("array dimensions cannot exceed INT_MAX");
93-
}
94-
SEXP ans = PROTECT(::Rcpp::wrap(objCopy.data(), objCopy.data() + size));
95-
if ( T::ColsAtCompileTime != 1 ) {
96+
SEXP ans = PROTECT(::Rcpp::wrap(objCopy.data(),
97+
objCopy.data() + size));
98+
if (needs_dim) {
9699
SEXP dd = PROTECT(::Rf_allocVector(INTSXP, 2));
97100
int *d = INTEGER(dd);
98101
d[0] = m;

0 commit comments

Comments
 (0)