A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://speakerdeck.com/jimhester/cpp11-welding-r-and-c-plus-plus below:

cpp11 - welding R and C++

  • Not ALTREP aware SEXP sum_vec_c(SEXP x) { int sum =

    0; int* p = INTEGER(x); for (R_xlen_t i = 0; i < Rf_xlength(x); ++i) { sum = sum + p[i]; } return Rf_ScalarInteger(sum); } x <- 1:10000 sum_vec_c(x) #> [1] 50005000 .Internal(inspect(x)) #> @1351f7858 13 INTSXP g0c0 [REF(65535)] 1 : 10000 (expanded) lobstr::obj_sizes(x) #> 40,728 B

  • Not ALTREP aware SEXP sum_vec_c(SEXP x) { int sum =

    0; int* p = INTEGER(x); for (R_xlen_t i = 0; i < Rf_xlength(x); ++i) { sum = sum + p[i]; } return Rf_ScalarInteger(sum); } x <- 1:10000 sum_vec_c(x) #> [1] 50005000 .Internal(inspect(x)) #> @1351f7858 13 INTSXP g0c0 [REF(65535)] 1 : 10000 (expanded) lobstr::obj_sizes(x) #> 40,728 B

  • Not ALTREP aware SEXP sum_vec_c(SEXP x) { int sum =

    0; int* p = INTEGER(x); for (R_xlen_t i = 0; i < Rf_xlength(x); ++i) { sum = sum + p[i]; } return Rf_ScalarInteger(sum); } x <- 1:10000 sum_vec_c(x) #> [1] 50005000 .Internal(inspect(x)) #> @1351f7858 13 INTSXP g0c0 [REF(65535)] 1 : 10000 (expanded) lobstr::obj_sizes(x) #> 40,728 B

  • Not ALTREP aware SEXP sum_vec_c(SEXP x) { int sum =

    0; int* p = INTEGER(x); for (R_xlen_t i = 0; i < Rf_xlength(x); ++i) { sum = sum + p[i]; } return Rf_ScalarInteger(sum); } x <- 1:10000 sum_vec_c(x) #> [1] 50005000 .Internal(inspect(x)) #> @1351f7858 13 INTSXP g0c0 [REF(65535)] 1 : 10000 (expanded) lobstr::obj_sizes(x) #> 40,728 B

  • ALTREP aware SEXP sum_vec_c2(SEXP x) { int sum = 0;

    for (R_xlen_t i = 0; i < Rf_xlength(x); ++i) { sum = sum + INTEGER_ELT(x, i); } return Rf_ScalarInteger(sum); } x <- 1:10000 sum_vec_c2(x) #> [1] 50005000 .Internal(inspect(x)) #> @103e50f80 13 INTSXP g0c0 [REF(65535)] 1 : 10000 (compact) lobstr::obj_sizes(x) #> 680 B

  • ALTREP aware SEXP sum_vec_c2(SEXP x) { int sum = 0;

    for (R_xlen_t i = 0; i < Rf_xlength(x); ++i) { sum = sum + INTEGER_ELT(x, i); } return Rf_ScalarInteger(sum); } x <- 1:10000 sum_vec_c2(x) #> [1] 50005000 .Internal(inspect(x)) #> @103e50f80 13 INTSXP g0c0 [REF(65535)] 1 : 10000 (compact) lobstr::obj_sizes(x) #> 680 B

  • ALTREP aware SEXP sum_vec_c2(SEXP x) { int sum = 0;

    for (R_xlen_t i = 0; i < Rf_xlength(x); ++i) { sum = sum + INTEGER_ELT(x, i); } return Rf_ScalarInteger(sum); } x <- 1:10000 sum_vec_c2(x) #> [1] 50005000 .Internal(inspect(x)) #> @103e50f80 13 INTSXP g0c0 [REF(65535)] 1 : 10000 (compact) lobstr::obj_sizes(x) #> 680 B

  • ALTREP aware SEXP sum_vec_c3(SEXP x) { int sum = 0;

    int buf[1024]; R_xlen_t i = 0; R_xlen_t n = Rf_xlength(x); while(i < n - 1024) { INTEGER_GET_REGION(x, i, 1024, buf); for (R_xlen_t j = 0; j < 1024; ++j) { sum = sum + buf[j]; } i += 1024; } R_xlen_t extra = n - i; INTEGER_GET_REGION(x, i, extra, buf); for (R_xlen_t j = 0; j < extra; ++j) { sum = sum + buf[j]; } return Rf_ScalarInteger(sum); } } x <- 1:10000 sum_vec_c3(x) #> [1] 50005000 .Internal(inspect(x)) #> @1342a4be0 13 INTSXP g0c0 #> [REF(65535)] 1 : 10000 (compact) lobstr::obj_sizes(x) #> 680 B

  • ALTREP aware SEXP sum_vec_c3(SEXP x) { int sum = 0;

    int buf[1024]; R_xlen_t i = 0; R_xlen_t n = Rf_xlength(x); while(i < n - 1024) { INTEGER_GET_REGION(x, i, 1024, buf); for (R_xlen_t j = 0; j < 1024; ++j) { sum = sum + buf[j]; } i += 1024; } R_xlen_t extra = n - i; INTEGER_GET_REGION(x, i, extra, buf); for (R_xlen_t j = 0; j < extra; ++j) { sum = sum + buf[j]; } return Rf_ScalarInteger(sum); } } x <- 1:10000 sum_vec_c3(x) #> [1] 50005000 .Internal(inspect(x)) #> @1342a4be0 13 INTSXP g0c0 #> [REF(65535)] 1 : 10000 (compact) lobstr::obj_sizes(x) #> 680 B

  • ALTREP aware SEXP sum_vec_c3(SEXP x) { int sum = 0;

    int buf[1024]; R_xlen_t i = 0; R_xlen_t n = Rf_xlength(x); while(i < n - 1024) { INTEGER_GET_REGION(x, i, 1024, buf); for (R_xlen_t j = 0; j < 1024; ++j) { sum = sum + buf[j]; } i += 1024; } R_xlen_t extra = n - i; INTEGER_GET_REGION(x, i, extra, buf); for (R_xlen_t j = 0; j < extra; ++j) { sum = sum + buf[j]; } return Rf_ScalarInteger(sum); } } x <- 1:10000 sum_vec_c3(x) #> [1] 50005000 .Internal(inspect(x)) #> @1342a4be0 13 INTSXP g0c0 #> [REF(65535)] 1 : 10000 (compact) lobstr::obj_sizes(x) #> 680 B

  • ALTREP aware SEXP sum_vec_c3(SEXP x) { int sum = 0;

    int buf[1024]; R_xlen_t i = 0; R_xlen_t n = Rf_xlength(x); while(i < n - 1024) { INTEGER_GET_REGION(x, i, 1024, buf); for (R_xlen_t j = 0; j < 1024; ++j) { sum = sum + buf[j]; } i += 1024; } R_xlen_t extra = n - i; INTEGER_GET_REGION(x, i, extra, buf); for (R_xlen_t j = 0; j < extra; ++j) { sum = sum + buf[j]; } return Rf_ScalarInteger(sum); } } x <- 1:10000 sum_vec_c3(x) #> [1] 50005000 .Internal(inspect(x)) #> @1342a4be0 13 INTSXP g0c0 #> [REF(65535)] 1 : 10000 (compact) lobstr::obj_sizes(x) #> 680 B


  • RetroSearch is an open source project built by @garambo | Open a GitHub Issue

    Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

    HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4