File tree 1 file changed +9
-6
lines changed
1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -81,18 +81,21 @@ namespace Rcpp{
81
81
// for plain dense objects
82
82
template <typename T>
83
83
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;
84
90
typename Eigen::internal::conditional<
85
91
T::IsRowMajor,
86
92
Eigen::Matrix<typename T::Scalar,
87
93
T::RowsAtCompileTime,
88
94
T::ColsAtCompileTime>,
89
95
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) {
96
99
SEXP dd = PROTECT (::Rf_allocVector (INTSXP, 2 ));
97
100
int *d = INTEGER (dd);
98
101
d[0 ] = m;
You can’t perform that action at this time.
0 commit comments