search for: cxxfunction

Displaying 20 results from an estimated 23 matches for "cxxfunction".

2020 Nov 21
3
Two ALTREP questions
...l(inspect(structure(1:6, dim = c(2L,3L)))) .Internal(inspect({x <- 1:6;attr(x, "dim") <- c(2L,3L);x})) .Internal(inspect({x <- 1:6;attributes(x)<- list(dim = c(2L,3L));x})) ``` The only way to make an ALTREP matrix is to use the C level function ``` attachAttrib <- inline::cxxfunction( signature(x = "SEXP", attr = "SEXP" ) , ' SET_ATTRIB(x,attr); return(R_NilValue); ') x <- 1:6 attachAttrib(x, pairlist(dim = c(2L, 3L))) .Internal(inspect(x)) ``` Since the matrix, or adding attributes, is a common need for the object operation, I wonder if this mis...
2011 Apr 15
1
[Rcpp-devel] Find number of elements less than some number: Elegant/fastsolution needed
...& ( xx(i) > yy(j) ) ) { j++; } xx_(i) = j; } return (xx_); ' require(inline) require(RcppArmadillo) f1 <- function(x, y) { sort(length(y) - findInterval(-x, rev(-sort(y))));} f2 <- function(x, y) {x = sort(x); length(y) - findInterval(-x, rev(-sort(y)))} f3.a <- cxxfunction(signature(x="numeric", y="numeric"), src1, plugin='RcppArmadillo') f3 <- function(x,y) { x <- sort(x) y <- sort(y) return(f3.a(x,y)) } f4 <- cxxfunction(signature(x="numeric", y="numeric"), src, plugin='RcppArma...
2011 Feb 06
5
Help with integrating R and c/c++
Hi, I have been using R for close to two years now and have grown quite comfortable with the language. I am presently trying to implement an optimization routine in R (Newton Rhapson). I have some R functions that calculate the gradient and hessian (pre requisite matrices) fairly efficiently. Now, I have to call this function iteratively until some convergance criterion is reached. I think the
2013 May 24
0
Rcpp with OpenMP - Need example Makevars
...found: __ZTIN4Rcpp19index_out_of_boundsE With standard setup of the above Makevars I get the Symbol not found: omp_set_num_threads Inline also does not work: fb <- 'omp_set_num_threads(10); + #pragma omp parallel + { Rf_PrintValue(wrap("HALLO JUPP")); } + ' > funk <- cxxfunction( signature(), body=fb, plugin='Rcpp' ) error: ‘omp_set_num_threads’ was not declared in this scope How do set the PKG_LIBS -and eventually other variables- to all required values in a single statement? Could anyone provide me with a working Makevars example, please? Help will be much app...
2011 Dec 05
1
RcppArmadillo compilation error: R CMD SHLIB returns status 1
...= errors.n_cols; arma::mat simdata(m,n); simdata.row(0) = arma::zeros<arma::mat>(1,n); for (int row=1; row<m; row++) { simdata.row(row) = simdata.row(row-1)*trans(coeff)+errors.row(row); } return Rcpp::wrap(simdata); ' ## create the compiled function rcppSim <- cxxfunction(signature(a="numeric",e="numeric"), code,plugin="RcppArmadillo") ### END OF EXAMPLE ### Executing this inside R, returned the following: ERROR(s) during compilation: source code errors or compiler configuration errors! Program source: 1:...
2011 Oct 12
1
Error in Rcpp/inline (Windows XP)
...mericVector xa(a); + Rcpp::NumericVector xb(b); + int n_xa = xa.size(); + int n_xb = xb.size(); + + Rcpp::NumericVector xab(n_xa + n_xb - 1); + + for (int i = 0; i < n_xa; i++) + for (int j = 0; j < n_xb; j++) + xab[i + j] += xa[i] * xb[j]; + + return xab; + ' > > fun = cxxfunction( + signature(a = "numeric", b = "numeric"), + src, plugin = "Rcpp",verbose=T) >> setting environment variables: PKG_LIBS = C:/Program Files/R/R-2.13.0/library/Rcpp/lib/i386/libRcpp.a >> LinkingTo : Rcpp CLINK_CPPFLAGS = -I"C:/Progr...
2011 Nov 17
3
.Call in R
Hi R developers, I am new to this forum and hope someone can help me with .Call in R. Greatly appreciate any help! Say, I have a vector called "vecA" of length 10000, I generate a vector called "vecR" with elements randomly generated from Uniform[0,1]. Both vecA and vecR are of double type. I want to replace elements vecA by elements in vecR only if sum of elements in
2010 Jul 26
1
O/T good c/c++ code for LU decomposition
Dear R People: Could someone recommend a good c/c++ code (or Fortran) for LU decomposition, please? Sorry to bother about this. I'm trying to do some "non-R" work that requires a matrix inversion. Thanks, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodgess at gmail.com
2011 Dec 16
0
crash in using Rcpp and inline packages.
...ode is quite simple, but the R session always automatically crash after some running time. Does anyone here familiar with Rcpp and inline? What¡¯s the problem in the following code? I have checked the input values, no NA and other strange value exists. Thank you for your attention! > mkc <- cxxfunction( signature(fx0="vector",fy0="vector",fsp0="vector", x0="vector",y0="vector",sp0="vector",phyd0="matrix", rmax0="numeric",step0="numeric",binlength0="integer"),...
2011 Dec 16
0
Fw: crash in using Rcpp and inline packages.
...ode is quite simple, but the R session always automatically crash after some running time. Does anyone here familiar with Rcpp and inline? What¡¯s the problem in the following code? I have checked the input values, no NA and other strange value exists. Thank you for your attention! > mkc <- cxxfunction( signature(fx0="vector",fy0="vector",fsp0="vector", x0="vector",y0="vector",sp0="vector",phyd0="matrix", rmax0="numeric",step0="numeric",binlength0="integer"),...
2012 Oct 15
0
First time Rcpp user needs compiler help, I think
I am trying to write a C++ function to be called from R and have never done this before. I have done the following: require(Rcpp) require(inline) src <- 'blahblahblah' fun <- cxxfunction(signature(a="numeric",b="numeric"),src,plugin="Rcpp") That last line generates the error message: Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! In addition: Warning message: running com...
2011 Feb 20
2
Problem using F77_CALL(dgemm) in a package
Dear R-devel, I've written a numerical solver for SOCPs (second order cone programs) in R, and now I want to move most of the solver code into C for speed. I've written combined R/C packages before, but in this case I need to do matrix operations in my C code. As I have never done that before, I'm trying to write some simple examples to make sure I understand the basics. I am stuck
2020 Nov 21
0
[External] Two ALTREP questions
...variants of your examples for more than 64 elements. > This also brings > my second question, it seems like the ALTREP coercion function does not > handle attributes correctly. After the coercion, the ALTREP object will > lose its attributes. > ``` > coerceFunc <- inline::cxxfunction( signature(x = "SEXP", attr = "SEXP" ) , ' > SET_ATTRIB(x,attr); > return(Rf_coerceVector(x, REALSXP)); > ') >> coerceFunc(1:6, pairlist(dim = c(2L, 3L))) > [1] 1 2 3 4 5 6 >> coerceFunc(1:6 + 0L, pairlist(dim = c(2L, 3L))) > [,1] [,2] [,3]...
2012 May 03
1
Setting up a windows system for rcpp
...eps were to install MinGW 32 bit first, then installing Rtools, I disabled MinGW's entry in the PATH. I am trying to get the following code to work: library(Rcpp) library(inline) body <- ' NumericVector xx(x); return wrap( std::accumulate( xx.begin(), xx.end(), 0.0));' add <- cxxfunction(signature(x = "numeric"), body, plugin = "Rcpp", verbose=T) x <- 1 y <- 2 res <- add(c(x, y)) res I get the following error messages: >> setting environment variables: PKG_LIBS = C:/Users/Owe/Documents/R/win-library/2.15/Rcpp/lib/x64/libRcpp.a >>...
2010 Nov 22
4
How to call R from C
Hi all! I read R Extensions manual. But still I am not sure how to call R functions from C. Would any of you give me a sample C code to show how to call R functions - for instance, time series functions - from C in the embedded way of C code? [[alternative HTML version deleted]]
2011 Feb 17
2
Newbie Rccp module question. "Failed to initialize module pointer"???
Hi all. I started looking at Rcpp, which looks pretty great, actually. At the moment just trying to compile a module to get a feel how it all works without fully understanding how all the pieces fit together. Basically, i took the first example from Rcpp modules vignette: fun.cpp ======================== #include <Rcpp.h> #include <math.h> using namespace Rcpp; double
2010 Jun 19
2
Call by reference or suggest workaround
I have written code to compute multi-indices in R [1] and due to the recursive nature of the computation I need to pass around the *same* matrix object (where each row corresponds to one multi-index). As pass by reference wasn't the default behavior I declared a global matrix (mat) and used the <<- operator to write to the global matrix. So the usage would be to call genMultiIndices(3,2)
2011 Sep 20
2
Is it possible to pass a function argument from R to compiled code in C?
I have a function in R that takes another function as argument: f <- function(g, ...) { #g is expected to be a function } I want to see if there is a way to implement "f" in C and calling it from R using ".C" interface. I know that I can use function pointers for my C implementation, but I imagine it's going to be nearly impossible to pass a function from R to C. Are
2010 Oct 27
2
must .Call C functions return SEXP?
For using R's .Call interface to C functions, all the examples I've seen have the C function return type SEXP. Why? What does R actually do with this return type? What happens if I *don't* return a SEXP? Reason I ask, is I've written some R code which allocates two long lists, and then calls a C function with .Call. My C code writes to those two pre-allocated lists, thus, I
2010 Nov 15
1
SEXP and slots
...s used) an Rcpp::S4 class that can be used to deal with slots. Here is a complete example using Rcpp and inline: require( Rcpp) require( inline ) setClass("example", representation ( size = "numeric", id = "character" ) ) fx <- cxxfunction( signature(x = "example"), ' S4 obj(x) ; obj.slot( "size" ) = 10 ; obj.slot( "id" ) = "foo" ; return obj ; ', plugin = "Rcpp" ) str( fx( new("example", size=4, id="id_value") ) ) But as Martin says...