| 578 | |
| 579 | template <typename T, typename STORAGE> |
| 580 | inline SEXP wrap_dispatch_matrix_primitive(const T& object) { |
| 581 | const int RTYPE = ::Rcpp::traits::r_sexptype_traits<STORAGE>::rtype; |
| 582 | int nr = object.nrow(), nc = object.ncol(); |
| 583 | Shield<SEXP> res(Rf_allocVector(RTYPE, nr*nc)); |
| 584 | |
| 585 | int k=0; |
| 586 | STORAGE* p = r_vector_start< RTYPE>(res); |
| 587 | for (int j=0; j<nc; j++) |
| 588 | for (int i=0; i<nr; i++, k++) |
| 589 | p[k] = object(i,j); |
| 590 | Shield<SEXP> dim(Rf_allocVector(INTSXP, 2)); |
| 591 | INTEGER(dim)[0] = nr; |
| 592 | INTEGER(dim)[1] = nc; |
| 593 | Rf_setAttrib(res, R_DimSymbol , dim); |
| 594 | return res; |
| 595 | } |
| 596 | |
| 597 | template <typename T> |
| 598 | inline SEXP wrap_dispatch_matrix_not_logical(const T& object, ::Rcpp::traits::r_type_primitive_tag) { |