[Rcpp-commits] r3321 - pkg/int64/inst/include/int64

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Nov 11 12:35:13 CET 2011


Author: romain
Date: 2011-11-11 12:35:11 +0100 (Fri, 11 Nov 2011)
New Revision: 3321

Modified:
   pkg/int64/inst/include/int64/LongVector.h
Log:
added logical -> [u]int64 conversion

Modified: pkg/int64/inst/include/int64/LongVector.h
===================================================================
--- pkg/int64/inst/include/int64/LongVector.h	2011-11-11 05:45:30 UTC (rev 3320)
+++ pkg/int64/inst/include/int64/LongVector.h	2011-11-11 11:35:11 UTC (rev 3321)
@@ -58,6 +58,24 @@
                             R_PreserveObject(data) ;  
                             break ;
                         }
+                    case LGLSXP:
+                        {
+                           int n = Rf_length(x) ;
+                            SEXP y = PROTECT( Rf_allocVector( VECSXP, n ) ) ;
+                            int hb, lb ;
+                            LONG tmp ;
+                            int* p_i_x = INTEGER(x) ;
+                            for( int i=0; i<n; i++){
+                                tmp = (LONG) p_i_x[i] ;
+                                hb = internal::get_high_bits<LONG>(tmp) ;
+                                lb = internal::get_low_bits<LONG>(tmp) ;
+                                SET_VECTOR_ELT( y, i, int64::internal::int2(hb,lb) ) ;    
+                            }
+                            UNPROTECT(1) ; // y
+                            data = y ;
+                            R_PreserveObject(data) ;  
+                            break ;
+                         }
                     case REALSXP: 
                         {
                             int n = Rf_length(x) ;



More information about the Rcpp-commits mailing list