[Rcpp-commits] r3297 - pkg/Rcpp/inst/include/Rcpp/internal
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Nov 6 20:46:38 CET 2011
Author: romain
Date: 2011-11-06 20:46:37 +0100 (Sun, 06 Nov 2011)
New Revision: 3297
Modified:
pkg/Rcpp/inst/include/Rcpp/internal/export.h
Log:
implementing export_indexing for int64_t and uint64_t for completeness (we dont actually use those in Rcpp, but we do in other child packages : RcppArmadillo, etc ...
Modified: pkg/Rcpp/inst/include/Rcpp/internal/export.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/internal/export.h 2011-11-06 19:25:18 UTC (rev 3296)
+++ pkg/Rcpp/inst/include/Rcpp/internal/export.h 2011-11-06 19:46:37 UTC (rev 3297)
@@ -165,7 +165,56 @@
}
}
+ /* indexing int64_t */
template <typename T, typename value_type>
+ void export_indexing__dispatch( SEXP x, T& res, ::Rcpp::traits::r_type_int64_tag ) {
+ int n = Rf_length(x) ;
+ if( Rf_inherits( x, "int64")){
+ Rcpp::int64::LongVector<int64_t> data(x) ;
+ for( int i=0; i<n; i++){
+ res[i] = data.get(i) ;
+ }
+ } else if( TYPEOF(x) == INTSXP ){
+ int* p_i_x = INTEGER(x) ;
+ for( int i=0; i<n; i++){
+ res[i] = (int64_t)p_i_x[i] ;
+ }
+ } else if( TYPEOF(x) == REALSXP ){
+ double* p_d_x = REAL(x) ;
+ for( int i=0; i<n; i++){
+ res[i] = (int64_t)p_d_x[i] ;
+ }
+ } else {
+ Rf_error( "expecting an int64 an integer or a numeric vector" );
+ }
+ }
+
+ /* indexing int64_t */
+ template <typename T, typename value_type>
+ void export_indexing__dispatch( SEXP x, T& res, ::Rcpp::traits::r_type_uint64_tag ) {
+ int n = Rf_length(x) ;
+ if( Rf_inherits( x, "uint64")){
+ Rcpp::int64::LongVector<uint64_t> data(x) ;
+ for( int i=0; i<n; i++){
+ res[i] = data.get(i) ;
+ }
+ } else if( TYPEOF(x) == INTSXP ){
+ int* p_i_x = INTEGER(x) ;
+ for( int i=0; i<n; i++){
+ res[i] = (uint64_t)p_i_x[i] ;
+ }
+ } else if( TYPEOF(x) == REALSXP ){
+ double* p_d_x = REAL(x) ;
+ for( int i=0; i<n; i++){
+ res[i] = (uint64_t)p_d_x[i] ;
+ }
+ } else {
+ Rf_error( "expecting an uint64 an integer or a numeric vector" );
+ }
+ }
+
+
+ template <typename T, typename value_type>
void export_indexing( SEXP x, T& res ) {
export_indexing__dispatch<T,value_type>(
x,
More information about the Rcpp-commits
mailing list