Re: [Rcpp-devel] How to use https://github.com/jjallaire/rcpp-gallery/blob/gh-pages/src/2013-01-05-r-function-from-c++.cpp?

2013-05-23 Thread Xiao He
}' ) Both methods let you directly call the function callFunction(x, f) (without having to use .Call()) callFunction(rnorm(30), sum) On Thu, May 23, 2013 at 9:14 PM, Peng Yu wrote: > Hi, > > I'm able to compile 2013-01-05-r-function-from-c++.cpp to the .so > file. B

Re: [Rcpp-devel] How to put the code 2013-01-05-r-function-from-c++.cpp in the src/ directory of a package?

2013-05-25 Thread Dirk Eddelbuettel
On 25 May 2013 at 06:50, Peng Yu wrote: | Hi Dirk, | | Here is what I got. Note that I have to used .Call and change the | arguments to the cpp function as SEXP and convert them to Function and | NumericVector inside the cpp function. | | But the example 2013-01-05-r-function-from-c++.cpp takes

Re: [Rcpp-devel] How to put the code 2013-01-05-r-function-from-c++.cpp in the src/ directory of a package?

2013-05-24 Thread Dirk Eddelbuettel
On 24 May 2013 at 05:17, Peng Yu wrote: | I want to put the C++ function "callFunction" in a cpp file in src/ | directory of an R package and use R (in R/) to call such a function. | Because I want to avoid the compilation need each time to use the | function. Could anybody show me an e

Re: [Rcpp-devel] How to put the code 2013-01-05-r-function-from-c++.cpp in the src/ directory of a package?

2013-05-25 Thread Peng Yu
Hi Dirk, Here is what I got. Note that I have to used .Call and change the arguments to the cpp function as SEXP and convert them to Function and NumericVector inside the cpp function. But the example 2013-01-05-r-function-from-c++.cpp takes Function and NumericVector as arguments directly. This

[Rcpp-devel] How to use https://github.com/jjallaire/rcpp-gallery/blob/gh-pages/src/2013-01-05-r-function-from-c++.cpp?

2013-05-23 Thread Peng Yu
Hi, I'm able to compile 2013-01-05-r-function-from-c++.cpp to the .so file. But I'm not able to call "callFunction" in R does anybody know what the correct way is to call R functions in C++? Thanks. > dyn.load('2013-01-05-r-function-from-c++.so') > x <

Re: [Rcpp-devel] How to use https://github.com/jjallaire/rcpp-gallery/blob/gh-pages/src/2013-01-05-r-function-from-c++.cpp?

2013-05-23 Thread Peng Yu
eCpp("cpp_file_name.cpp "). Or if > you use the package inline, you can do the following inside R. > > cppFunction(' > NumericVector callFunction(NumericVector x, Function f) { >NumericVector res = f(x); > return res; > }' >

Re: [Rcpp-devel] Are there any C++ function name restrictions?

2013-05-29 Thread Dale Smith
Since you changed the function name, you can no longer call rcpp_hello_world() from R. Try calling the new function name. Better yet, start over, leave rcpp_hello_world code alone and add another .cpp, .h, and .R file with another function. Dale On May 29, 2013, at 8:41 PM, Asis Hallab wrote

Re: [Rcpp-devel] function within a function

2012-05-02 Thread Dirk Eddelbuettel
ntion use by R. You only need this when you call from R via .Call(). At the C++ level you are open to any other (visible) C++ function -- which is how we call other libraries. My last piece of advice would be to write a mock C++ solution first. Write a short main(), set up some data, call one functio

Re: [Rcpp-devel] Calling an internal do_* C level function

2013-10-14 Thread Romain Francois
ve an unusual signature, and I'm not sure what headers/linker directives I would need to include to get access to this function. I am aware that I could call the R level rank() function, but I'm trying to avoid the performance penalty. Thanks, -Mark Most of them are hidden. You can't ca

Re: [Rcpp-devel] calling R function triggers tryCatch() ???

2013-10-04 Thread Thomas Tse
e call(FUN, R_NilValue);   Language::Proxy proxy(call, 1);   proxy = x;   call.fast_eval();   Rcpp::Rcout << "after call" << std::endl;   return; } I tested the error handling behaviors in R: (AnyError() is R my implementation of a simplifed tryCatch(). It returns TRU

[Rcpp-devel] [Rcpp] How can i call a R function in Cpp source code?

2014-08-05 Thread super
Hello Rcppusers, I want to call a r function in Cpp code, e.g. int meanC( NumericVector x) { return mean(x,_["na.rm"]=TRUE); } Here function mean is a r function not rewrittened Rcpp version's mean. I do know one way to do this: int meanC( Function f,NumericVector x) {

[Rcpp-devel] Problem with calling a function in RcppArmadillo to R

2016-11-18 Thread Kokia Z
funs.h:137 So I try to call a kronecker function, the corresponding file in the fn_kron.hpp file are: 1) In "R": Rcpparma_hello_world <- function () { .Call ( 'fn_kron_hpp_rcpparma_hello_world', PACKAGE = 'fn_kron.hpp') }} Rc

Re: [Rcpp-devel] How to use https://github.com/jjallaire/rcpp-gallery/blob/gh-pages/src/2013-01-05-r-function-from-c++.cpp?

2013-05-23 Thread Xiao He
pile it from within R using sourceCpp("cpp_file_name.cpp "). > Or if > > you use the package inline, you can do the following inside R. > > > > cppFunction(' > > NumericVector callFunction(NumericVector x, Function f) { > >NumericVecto

Re: [Rcpp-devel] function within a function

2012-05-03 Thread Marie Auger-Methe
f2.h" SEXP f2(){ using namespace Rcpp; NumericVector x = f1(); x[0] = x[0] + 1; return x; } f2.h: #ifndef _fxwithinfx_f2_H #define _fxwithinfx_f2_H #include RcppExport SEXP f2() ; #endif f2.R: f2 <- function(){ .Call( "f2", PACKAGE = "fxwithinfx" ) } On 02/05

[Rcpp-devel] function not getting stored properly..

2018-03-23 Thread akshay kulkarni
dear members, I have created a function mygrpc using cppFunction using Rcpp. When I call the function after starting the R session, I get the following error: > mygrpc(xmc1,ygix,ygrpc) Error in .Call(, x, ygix, ygrpc) : NULL value passed as symbol address xmc1 is a matrix of OHLC data o

Re: [Rcpp-devel] calling R function triggers tryCatch() ???

2013-10-03 Thread Romain Francois
amp; FUN){ int n = x.nrow(); NumericVector result = no_init(n); for (int r = 0; r < n; r++) { Language call(FUN, x(r, _)) ; result[r] = as(call.fast_eval()); } return result; } or more efficiently: // [[Rcpp::export]] NumericVector rowApply(NumericMatrix& x, cons

Re: [Rcpp-devel] Problem with calling a function in RcppArmadillo to R

2016-11-18 Thread Dirk Eddelbuettel
superClass)) : | no support for long vectors�� ../include/Rinlinedfuns.h:137 That's an R function. Maybe it needs another change for x_len_t? | So I try to call a kronecker function, the corresponding file in the | fn_kron.hpp file are: The rest of your post is (and pardon my directness

[Rcpp-devel] call R internal adist function from Rcpp

2013-12-30 Thread contact AG STUDY
I need to call R adist function over a big vector, many times. Internally , adist is calling adist_full<https://github.com/SurajGupta/r-source/blob/e242a7ebfb1b9921b29e2c5f88411f5018b0f74f/src/main/agrep.c> defined in src/main/agrep.c. So wonder If I can call the c function adist_full di

Re: [Rcpp-devel] [Rcpp] How can i call a R function in Cpp source code?

2014-08-05 Thread Romain Francois
base") ; Function foo = base["mean"] Romain Le 5 août 2014 à 09:26, super a écrit : > Hello Rcppusers, > I want to call a r function in Cpp code, e.g. > int meanC( NumericVector x) { > return mean(x,_["na.rm"]=TRUE); > } > Here function mean is a r

Re: [Rcpp-devel] cost of .Call

2022-08-10 Thread Dirk Eddelbuettel
Hi Konrad, On 10 August 2022 at 08:22, konrad wrote: | I have a question regarding the cost of .Call. If I implement the | rosenbrock function in R and in Rcpp. The R version is substentially | faster then the C++ version. The Rcpp function is basically an R | function which calls the C

[Rcpp-devel] Question about variadic argument "..." in Rcpp

2012-07-17 Thread SHEN Fei
the background of my program is a little special, i will also call R functions in the C++ function that i pass f to. I knew that i can use Rcpp to call C++ functions in R, and use RInside to call R functions in C++. But can i use them both at the same time? I've tried "R -> C++ ->

Re: [Rcpp-devel] How to call a function from an R package in cpp code

2016-10-11 Thread Dirk Eddelbuettel
On 11 October 2016 at 15:54, Amina Shahzadi wrote: | I want to use dgev(x,shape=1,scale=1,location=0,log=FALSE) function of an R | package "FAdist" in the framework of Rcpp. How can I call that? | | For example for the Poisson distribution which is basic function of R I have | w

Re: [Rcpp-devel] Are there any C++ function name restrictions?

2013-05-29 Thread Asis Hallab
obar/ >From an interactive R shell I could call the function rcpp_hello_world() successfully. Then the very only thing I did was changing the function name rcpp_hello_world to conditionalProbabilityTables in three files src/rcpp_hello_world.h, src/rcpp_hello_world.cpp, and R/rcpp_hello_world.R Fi

[Rcpp-devel] How to set a default value when call a R function in Rcpp

2016-11-10 Thread Jingyu He
Hi, I'm writing a R package by Rcpp and I have a problem when setting default value when call a R function in Rcpp. Here is an example to pass a R function to C++, provided by http://adv-r.had.co.nz/Rcpp.html #include using namespace Rcpp;// [[Rcpp::export]]RObject callWithOne(Funct

Re: [Rcpp-devel] Using spatstat in Rcpp

2014-06-11 Thread Romain François
Hello, You seem to be confusing R namespaces and C++ namespaces and assuming you can call an R function as if it belonged to a C++ namespace. R functions and c++ functions are different things. You can do something like: // get the spatstat environment Environment spatstat

Re: [Rcpp-devel] function not getting stored properly..

2018-03-23 Thread JJ Allaire
Rcpp. When I call > the function after starting the R session, I get the following error: > > > mygrpc(xmc1,ygix,ygrpc) > Error in .Call(, x, ygix, ygrpc) : > NULL value passed as symbol address > > xmc1 is a matrix of OHLC data of a stock, while ygix and ygrpc are > fu

Re: [Rcpp-devel] calling and R function from rcpp and evaluation

2014-02-06 Thread Romain Francois
Hi Antonio, This is about how R evaluation works. Might not just be what you think it is. When you use Rcpp and therefore .Call things are evaluated fairly early, at least earlier than what would happen with R, etc … you can reproduce what R does by using promises. For example this work in

Re: [Rcpp-devel] [Rcpp] How can i call a R function in Cpp source code?

2014-08-05 Thread Sven E. Templer
ii), e.g.: http://www.mail-archive.com/search?q=call+R+function&l=rcpp-devel%40lists.r-forge.r-project.org or try yourself: http://www.mail-archive.com/rcpp-devel@lists.r-forge.r-project.org/ Nevertheless I liked the question and learned something today (thank you Romain). So the trend i

Re: [Rcpp-devel] [Rcpp] How can i call a R function in Cpp source code?

2014-08-05 Thread Dirk Eddelbuettel
ean(x); | } | with the error "can't convert SEXP to double" | How can i fix it ? Tks. With all due respect: i)you have not motivated why you need mean from R ii) how to call an R function from Rcpp as been discussed on this list probably half a dozen times by

Re: [Rcpp-devel] Grid Search in RcppParallel

2014-10-04 Thread Romain Francois
will always return a double. > Since Rcpp can call an R function I was hoping RcppParallel would allow me to > use a parallelFor to process the rows of the grid quickly. However, it keeps > crashing R, and I am wondering if this is because an R function cannot be > passed to Rcpp

Re: [Rcpp-devel] Defining template specialisation for wrap on Windows 64bit (Compilation error: 'result_type' does not name a type)

2013-10-04 Thread Renaud Gaujoux
ids declaration of 'operator()' with no type [-fpermissive] C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h: In member function 'int Rcpp::fixed_call< >::operator()()': C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:162:41: error: no matching function for call to '

Re: [Rcpp-devel] [Rcpp] How can i call a R function in Cpp source code?

2014-08-05 Thread Dirk Eddelbuettel
On 5 August 2014 at 16:25, Sven E. Templer wrote: | ii), e.g.: | | http://www.mail-archive.com/search?q=call+R+function&l=rcpp-devel%40lists.r-forge.r-project.org | | or try yourself: | | http://www.mail-archive.com/rcpp-devel@lists.r-forge.r-project.org/ Or stackoverfloww:

Re: [Rcpp-devel] Question about variadic argument "..." in Rcpp

2012-07-18 Thread Dirk Eddelbuettel
pp Module to treat the various argument ... | as _["..."]. But i'm still very confused. Would you please give me an example | to show how to use Rcpp to do the function transformation, especially when the | "..." argument is used. | | And since the background of my program is a little

Re: [Rcpp-devel] call R internal adist function from Rcpp

2013-12-30 Thread Dirk Eddelbuettel
Amine, On 30 December 2013 at 19:26, contact AG STUDY wrote: | I need to call R adist function over a big vector, many times. | Internally , adist is calling adist_full defined in src/main/agrep.c. So | wonder If I can call the c function adist_full directly from my c++ code. You may need to

Re: [Rcpp-devel] function not getting stored properly..

2018-03-23 Thread Dirk Eddelbuettel
-properly-in-r-console Akshay: Please do not cross-post. Dirk | J.J. | | On Fri, Mar 23, 2018 at 7:49 AM, akshay kulkarni | wrote: | | > dear members, | > | > | > I have created a function mygrpc using cppFunction using Rcpp. When I call | > the function after starting the R ses

Re: [Rcpp-devel] Calling an internal do_* C level function

2013-10-14 Thread Dirk Eddelbuettel
On 14 October 2013 at 19:41, Romain Francois wrote: | Most of them are hidden. You can't call them. For example: | | SEXP attribute_hidden do_rank(SEXP call, SEXP op, SEXP args, SEXP rho) | | The attribute_hidden hides the function. If you want this function to be | available as part of

[Rcpp-devel] How to call a function from an R package in cpp code

2016-10-10 Thread Amina Shahzadi
Hi Rcpp Friends I want to use dgev(x,shape=1,scale=1,location=0,log=FALSE) function of an R package "FAdist" in the framework of Rcpp. How can I call that? For example for the Poisson distribution which is basic function of R I have written the following code. #include using name

Re: [Rcpp-devel] [Rcpp] How can i call a R function in Cpp source code?

2014-08-05 Thread super
nvironment, e.g. Environment("package:base")["mean"] or Environment base("package:base") ; Function foo = base["mean"] Romain Le 5 août 2014 à 09:26, super a écrit : Hello Rcppusers, I want to call a r function in Cpp code, e.g. int meanC( Numeric

Re: [Rcpp-devel] Alternative way of calling R functions within C++

2016-08-03 Thread Kevin Ushey
pr min lq mean median uq max neval >> cppFuncall(x, fun) 1.3 1.3 1.391.3 1.4 83 1 >> RcppFuncall(x, fun) 7.2 7.1 7.136.9 6.8 89 1 >> fun(x) 1.0 1.0 1.001.0 1.0 1 1 >> >> So, o

[Rcpp-devel] Package built with Rcpp fails to install

2014-02-03 Thread Tal Galili
a 'Vector<19>') to 'RObject' (aka 'RObject_Impl') for 1st argument bool is_leaf(RObject x); ^ 3 errors generated. make: *** [cut_lower.o] Error 1 clang++ -std=c++11 -I/home/Hornik/tmp/R-d-clang/include -DNDEBUG -I/usr/local/

Re: [Rcpp-devel] cost of .Call

2022-08-10 Thread Avraham Adler
8:22, konrad wrote: > | I have a question regarding the cost of .Call. If I implement the > | rosenbrock function in R and in Rcpp. The R version is substentially > | faster then the C++ version. The Rcpp function is basically an R > | function which calls the C++ function using .Cal

Re: [Rcpp-devel] call R internal adist function from Rcpp

2013-12-30 Thread contact AG STUDY
ec 30, 2013 at 7:33 PM, Dirk Eddelbuettel wrote: > > Amine, > > On 30 December 2013 at 19:26, contact AG STUDY wrote: > | I need to call R adist function over a big vector, many times. > | Internally , adist is calling adist_full defined in src/main/agrep.c. So > | won

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-06 Thread Douglas Bates
d in >>>>> Rcpp/src/Module.cpp.  Is this intentional?  Should one or both of >>>>> those be a maybe_init() call?  I think as it stands the second call >>>>> will overwrite the contents created by the first call. >>>>> >>>>>

[Rcpp-devel] Call C++ Function into R function called in Rcpp

2015-01-04 Thread bbo...@tin.it
Dear list first of all happy new year. I have a question .. I would like to call rcpp function (so c++ function) into R function (optim for example) called into rcpp. I had prototype an example code and post below. (Using Rcpp::InternalFunction(&foo)) Is it correct the way I had used? T

[Rcpp-devel] expose functions dynamically

2017-12-04 Thread David Bellot
amically created function in R #include using namespace Rcpp; double foobar(int x) { return x*2.0; } void makef() { function("dynfoo",&foobar); } RCPP_MODULE(test1) { function("foobar",foobar); function("makef",&makef); } Then in R, I call

[Rcpp-devel] devtools::load_all() working differently for Rcpp >= 0.11.0

2014-07-03 Thread Finlay Scott
l() load_all("NewPackage") # The package recompiles, and I can see that the resulting *.o and *.so have been updated. # However, calling rcpp_hello_world() still returns the old output, i.e. the function called from R does not seem to have been updated. # Similarly, if I add a new

[Rcpp-devel] Calling an internal do_* C level function

2013-10-14 Thread Mark Fredrickson
at headers/linker directives I would need to include to get access to this function. I am aware that I could call the R level rank() function, but I'm trying to avoid the performance penalty. Thanks, -Mark ___ Rcpp-devel mailing list Rcpp-devel@

Re: [Rcpp-devel] Rcpp ISNAN slower than C ISNAN?

2016-12-14 Thread Johannes Kruisselbrink
C++ code a function call is used.) " http://www.hep.by/gnu/r-patched/r-exts/R-exts_133.html Definitions from the horse's mouth: https://github.com/wch/r-source/blob/trunk/src/include/R_ext/Arith.h#L66 This was also pointed out by Bill Dunlap and indeed seems to be the explanation for

Re: [Rcpp-devel] Alternative way of calling R functions within C++

2016-08-03 Thread George Vega Yon
red using Rcpp::function vs my > implementation vs > >> calling the function from R itself and this is what I got > >> > >> Unit: relative > >> expr min lq mean median uq max neval > >> cppFuncall(x, fun) 1.3 1.3 1.391.3 1.4 83 100

[Rcpp-devel] Call R function

2012-06-19 Thread bbo...@tin.it
Hello i would like to compute the following code ; Where R_user_F is a R function (i could write this function directly inin line but is only for example because i want to call an R function more complex): so when compile appear this error message: error: "cannot convert 'R

[Rcpp-devel] Call ++ funtion into R function called in rcpp

2015-01-04 Thread bbo...@tin.it
Dear list first of all happy new year. I have a question .. I would like to call rcpp function (so c++ function) into R function (optim for example) called into rcpp. I had prototype an example code and post below. (Using Rcpp::InternalFunction(&foo)) Is it correct the way I had used? T

Re: [Rcpp-devel] Grid Search in RcppParallel

2014-10-05 Thread JJ Allaire
expand.grid, then for each row of that matrix, > x, call f(x). For simplicity the function f will always return a double. > Since Rcpp can call an R function I was hoping RcppParallel would allow me > to use a parallelFor to process the rows of the grid quickly. However, it > kee

Re: [Rcpp-devel] Using Rcpp::Function in parallel with TBB mutex lock & a reference.

2025-02-08 Thread Dirk Eddelbuettel
library in R), all my other | computations are now implemented in C++ & thread friendly. Does this mean I | would have no other option but to go serial if I need to call R an function? Do | you have any alternative recommendations? I would really love to take advantage | of RcppParallel/TBB here,

Re: [Rcpp-devel] Package built with Rcpp fails to install

2014-02-03 Thread Dirk Eddelbuettel
ports.o | clang++ -std=c++11 -I/home/Hornik/tmp/R-d-clang/include -DNDEBUG   -I/usr/local/ | include -I"/home/Hornik/lib/R/Library/3.1/x86_64-linux-gnu/Rcpp/include"   | -fpic  -g -O3 -Wall -Wno-unused -pedantic -c cut_lower.cpp -o cut_lower.o | cut_lower.cpp:35:7: error: no matching functio

Re: [Rcpp-devel] Package built with Rcpp fails to install

2014-02-03 Thread Kevin Ushey
-O3 -Wall -Wno-unused -pedantic -c RcppExports.cpp -o RcppExports.o > clang++ -std=c++11 -I/home/Hornik/tmp/R-d-clang/include -DNDEBUG > -I/usr/local/include > -I"/home/Hornik/lib/R/Library/3.1/x86_64-linux-gnu/Rcpp/include" -fpic -g > -O3 -Wall -Wno-unused -pedantic -

[Rcpp-devel] Rcpp.package.create(attributes=TRUE)

2013-02-26 Thread Greg Minshall
hi. if i Rcpp.package.skeleton(), i get this single R file, anRpackage/R/rcpp_hello_world.R: rcpp_hello_world <- function(){ .Call( "rcpp_hello_world", PACKAGE = "anRpackage" ) } on the other hand, if i Rcpp.package.skeleton(attributes=TRUE), i get two

Re: [Rcpp-devel] [Rcpp] How can i call a R function in Cpp source code?

2014-08-05 Thread super
ean=Environment("package::base")["mean"]; >|return mean(x); >| } >| with the error "can't convert SEXP to double" >| How can i fix it ? Tks. > >With all due respect: > > i)you have not motivated why you need mean from R > > ii) how

Re: [Rcpp-devel] How to set a default value when call a R function in Rcpp

2016-11-10 Thread Dirk Eddelbuettel
On 11 November 2016 at 05:16, Jingyu He wrote: | I'm writing a R package by Rcpp and I have a problem when setting default value | when call a R function in Rcpp. Here is an example to pass a R function to C++, | provided by http://adv-r.had.co.nz/Rcpp.html | | #include | using namespace

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-06 Thread Douglas Bates
;>> Perhaps Romain or Dirk could clarify for me when init_Rcpp_cache >>> should be called.  It appears to be getting called twice, once >>> explicitly in the .onLoad expression in Rcpp/R/zzz.R and once >>> implicitly by being part of the R_init_Rcpp function define

[Rcpp-devel] Rcpp 0.11.0 Module error

2014-03-03 Thread Ian Fellows
]’ RcppModule.cpp:372: instantiated from here /Users/ianfellows/Library/R/3.0/library/Rcpp/include/Rcpp/Module.h:331: error: no matching function for call to ‘Rcpp::Reference_Impl::Reference_Impl()’ /Users/ianfellows/Library/R/3.0/library/Rcpp/include/Rcpp/Reference.h:56: note: candid

[Rcpp-devel] More support of STL algorithms

2010-02-18 Thread Romain Francois
Hi, I just commited Rcpp::fixed_call to support uses of STL algorithms such as std::generate. Here is an example that mimics : > lapply( 1:10, function(n) rnorm(10) ) using Rcpp API : funx <- cfunction(signature(), ' Language call( Function("rnorm"

Re: [Rcpp-devel] Why inline function is much faster than .Call?

2012-08-28 Thread Dirk Eddelbuettel
elf 2 test_inline(xx) 1000 6.173 1.00 6.144 3 .Call("test", xx, package = "test") 1000 6.228 1.008910 6.217 1test(xx) 1000 6.657 1.078406 6.280 edd@max:/tmp$ edd@max:/tmp$ r pengyu3.r

[Rcpp-devel] Have I noticed memory management bug in RcppArmadillo or is this the intended behaviour?

2011-10-27 Thread Slava Razbash
Hello, I noticed that a C++ function that I using RcppArmadillo and some R API was increasing R's memory usage after exiting and and ecan after a call to gc(). So I ran some "tests", which I will describe below, along with my observations. My question are: (1) Am I observi

Re: [Rcpp-devel] Call R function

2012-06-20 Thread Douglas Bates
On Wed, Jun 20, 2012 at 12:52 AM, bbo...@tin.it wrote: > Hello i would like to compute the following code ; > > Where R_user_F is a R function  (i could write this function directly inin > line but is only for example because i want to call an R function more > complex): > so w

Re: [Rcpp-devel] Creating a Rcpp package : Visual C++ Library error

2012-07-17 Thread Valentin Mansion
As I was going through the Rcpp Quick Reference Guide, I just found a solution to my problem : In the .R file of my package, in the .Call function, there was no argument telling my function needed an input variable... I added this, rebuilt/installed the package, and now it works. The new .R file

Re: [Rcpp-devel] Rcpp matrix generation crashes my R session

2013-06-22 Thread Marc Jekel
created a R-package with the function included, thank you Simon! Simon: I call the function from a program in R. The function creates a matrix based on the input that I need for a neural network. Best, Marc I actually do not know, for what you are using this function.are you calling

Re: [Rcpp-devel] Package built with Rcpp fails to install

2014-02-03 Thread Romain Francois
x27;Vector<19>') to 'value_type' (aka 'Rcpp::RObject_Impl') >> for 1st argument >> push_back(value_type&& __x) >> ^ >> cut_lower.cpp:84:7: error: no matching function for call to 'is_leaf' >> if(is_leaf( tree )) { &

Re: [Rcpp-devel] Question on performance and strategy

2018-09-22 Thread Jordi Molins
in R to CPU-paralellize the third > | one (and for each variable of the third one, the R function is called, > and > | then internally, RcppArrayFire uses GPUs). > > Just because you want to access ONE gpu device N times does not make it N > gpus. > > And as you have only one GP

Re: [Rcpp-devel] Setting R seed from Cpp (continued)

2013-06-10 Thread Simon Zehnder
Hi Matteo, this is an interesting post. My assumption is, that as in the first approach you call an R function which is implemented as a pointer (or reference to an R function) this function always has access to the RNG scope. Whereas in the second approach you call nested, which is a CPP

Re: [Rcpp-devel] Rcpp syntactic sugar equivalent for R's optimize() function

2014-02-28 Thread Smith, Dale (Norcross)
tions has been discussed in this list about a month ago: | | http://r.789695.n4.nabble.com/Linking-to-native-routines-in-other-pack | ages-tt4683969.html#none Not exactly. That question was about calling from another package for which the calling-registered-functions approach was discussed; Hi

[Rcpp-devel] How to put the code 2013-01-05-r-function-from-c++.cpp in the src/ directory of a package?

2013-05-24 Thread Peng Yu
Hi, I want to put the C++ function "callFunction" in a cpp file in src/ directory of an R package and use R (in R/) to call such a function. Because I want to avoid the compilation need each time to use the function. Could anybody show me an example how to do so? Thanks. https://

Re: [Rcpp-devel] [Rd] must .Call C functions return SEXP?

2010-10-28 Thread Dominick Samperi
t;> > Subject: Re: [Rd] must .Call C functions return SEXP? > >> > > >> > On Thu, Oct 28, 2010 at 12:15:56AM -0400, Simon Urbanek wrote: > >> > > >> > > > Reason I ask, is I've written some R code which allocates two long > >&g

Re: [Rcpp-devel] Setting seed using Rcpp

2018-02-07 Thread Dirk Eddelbuettel
, which i can use | it inside c++ code? In short, no. Slightly longer: All Rcpp code is set up to be used _from R_ so by design you are always in R before you call code containing Rcpp. So just call the R function set.seed(...) as we work hard to make sure the state is properly set and passed

Re: [Rcpp-devel] devtools::load_all() working differently for Rcpp >= 0.11.0

2014-07-03 Thread Kevin Ushey
nction with attributes in the C++ source code, and then reload the package > using the devtools function load_all(). This would recompile the source > code, and update the RcppExports.R and .cpp files as necessary. The new > exported function would then be immediately available to the curren

Re: [Rcpp-devel] Using Rcpp::Function in parallel with TBB mutex lock & a reference.

2025-02-10 Thread Kumar MS
> | would have no other option but to go serial if I need to call R an > function? Do > | you have any alternative recommendations? I would really love to take > advantage > | of RcppParallel/TBB here, as I have heavily exploited RcppParallel to > | parallelize everything else. >

Re: [Rcpp-devel] R package: minqa (fwd)

2010-03-15 Thread Romain Francois
Function class are not available without >> the flag, as I realized this morning. >> >> I'll check how to call an R function without arguments in Rcpp if the >> -std=c++0x flag is not set and commit a fix. >> >> 2010/3/15 Katharine Mullen: >>> FYI >

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-06 Thread Douglas Bates
) that test didn't >>>>> show any problems.  I'm at a bit of a loss where to go on this. >>>> >>>> Perhaps Romain or Dirk could clarify for me when init_Rcpp_cache >>>> should be called.  It appears to be getting called twice, once >&

Re: [Rcpp-devel] dmvnorm() of mvtnorm using RcppArmadillo

2019-12-19 Thread Dirk Eddelbuettel
On 20 December 2019 at 07:50, Shaami wrote: | #include | #include That is not used as you call the R function. In short, don't call the R function. I buys you nothing. You were told to look into using the API from that header. I would do that if I were you. | using namespace Rcpp; |

Re: [Rcpp-devel] Rcpp.package.create(attributes=TRUE)

2013-02-26 Thread Dirk Eddelbuettel
On 26 February 2013 at 21:27, Greg Minshall wrote: | hi. if i Rcpp.package.skeleton(), i get this single R file, | anRpackage/R/rcpp_hello_world.R: | | rcpp_hello_world <- function(){ | .Call( "rcpp_hello_world", PACKAGE = "anRpackage" ) | } | | |

[Rcpp-devel] Is it possible to call an R internal C function from Rcpp?

2015-03-02 Thread steven pav
hi all; I want to write the density function for the doubly non-central F distribution using Rcpp. The algorithm (from Paolella's Intermediate Probability, listing 10.8) computes the weighted sum of the PDF function of the singly non-central F distribution. This is available in R via df

[Rcpp-devel] Grid Search in RcppParallel

2014-10-04 Thread Jeffrey Wong
I am trying to use RcppParallel to do a fast grid search. The idea is to construct a matrix using R's expand.grid, then for each row of that matrix, x, call f(x). For simplicity the function f will always return a double. Since Rcpp can call an R function I was hoping RcppParallel would all

Re: [Rcpp-devel] [Rcpp] How can i call a R function in Cpp source code?

2014-08-05 Thread Dirk Eddelbuettel
;)["mean"]; | >|return mean(x); | >| } | >| with the error "can't convert SEXP to double" | >| How can i fix it ? Tks. | > | >With all due respect: | > | > i)you have not motivated why you need mean from R | > | > ii) how to call

Re: [Rcpp-devel] Alternative way of calling R functions within C++

2016-08-03 Thread Kevin Ushey
eing evaluated, but right now it's the only way to safely execute an R function in a C++ context while respecting all other active handlers. In short, the Rcpp::Function implementation is designed to be as safe + correct as possible, with the downside being that it's slower. However, we gener

Re: [Rcpp-devel] RcppEigen: Windows binary from CRAN crashes R, but not when installing from source.

2014-10-16 Thread Dirk Eddelbuettel
; VectorXd IneqT = (theta*Ineq.transpose()); return 0; } /*** R # the following is equivalent to mptmin::R/minimal.cpp # but shorter and easier; also removed the leading dot oneSample2 <- function(Sx, Ineq) { #.Call("determinant2", Sx, Ineq, PACKAGE = "MPTbug") determina

[Rcpp-devel] New function for exposing C++ classes

2013-10-09 Thread John Chambers
The function exposeClass() has been added to Rcpp. The idea is to call it to create C++ and R files in a package source in order to export a C++ class, given basic information about the class. The function writes the Module source in C++ and a corresponding call to setRcppClass in R. Like

Re: [Rcpp-devel] Problem installing even default Rcpp skeleton package

2012-05-09 Thread Dirk Eddelbuettel
llo_world_Rcpp" | | Your package is called "RcppSkeleton", isn't it? If so, that should be | reflected in your PACKAGE argument in .Call, eg: | | .Call("rcpp_hello_world", PACKAGE="RcppSkeleton") +1 And that is what should have gotten filled in as rcpp_h

Re: [Rcpp-devel] Rcpp: Error: not compatible with requested type

2014-10-03 Thread Dirk Eddelbuettel
Oh, and I missed one call to a subordinate function. So add // [[Rcpp::export]] SEXP newCompQuant2(int n, int M, Rcpp::Function f) { SEXP res = compquantRcpp2(n, M, f); return res; } and at the bottom call it: res <- newCompQuant2(n=50, M=10^3, f=rnorm) print(str(res)) and then

Re: [Rcpp-devel] Rcpp ISNAN slower than C ISNAN?

2016-12-14 Thread Christian Gunning
ed my interest. Based on your previous email, I'm guessing you found this? "Currently in C code ISNAN is a macro calling isnan. (Since this gives problems on some C++ systems, if the R headers is called from C++ code a function call is used.) " http://www.hep.by/gnu/r-patched/r-exts

Re: [Rcpp-devel] Rcpp

2010-05-11 Thread Romain Francois
you have a existing function, it is usually better to keep it as is and write a simple .Call compatible wrapper that receives the data from R, call you existing function and transform the results back into R compatible data. .Call compatible means: - the function has C linkage and calling convent

Re: [Rcpp-devel] Dynamic Wrapping and Recursion with Rcpp - using an R function?

2013-07-27 Thread Romain Francois
u really want the flexibility of being able to call any R function, or can you come up with a list of operations you'd do on terminal nodes of your tree ? what do you want to do with your dendrograms ? Romain Le 26/07/13 17:06, Tal Galili a écrit : Hello all, I would like to write an Rc

[Rcpp-devel] Memory Leak found and resolved

2012-08-26 Thread Silkworth,David J.
gt; The resolution was quite simple. I ended up calling an R wrapper function for the replacement ns function that had been written in Rcpp. I lost a measurable amount of performance, but by doing this I believe the R garbage collector was permitted to do its work. For the wrapper call in Rcp

Re: [Rcpp-devel] RcppEigen: Windows binary from CRAN crashes R, but not when installing from source.

2014-10-16 Thread Dirk Eddelbuettel
nspose()); | | return 0; | } | | /*** R | | # the following is equivalent to mptmin::R/minimal.cpp | # but shorter and easier; also removed the leading dot | oneSample2 <- function(Sx, Ineq) { | #.Call("determinant2", Sx, Ineq, PACKAGE = "MPTbug") | determinant2(Sx, I

Re: [Rcpp-devel] R.e. Rcpp equivalent of sample()?

2011-05-14 Thread Dirk Eddelbuettel
m R and use it in C++. | Honestly, I've found it easiest to just import sample() from R (in the | stats namespace). Two things to note: | | 1. Performance -- there's a penalty for going back to R, but it's per | function call. So, you can pull a vector result of sample into an | inte

[Rcpp-devel] Another 'Error: not compatible with requested type'

2015-08-07 Thread Fabio Tordini
ring samfile, int nwrks, float e_lm, int chunk) never had any problems with that. today it started to crash with the above error. Weirdly, this happens only when I call the R function, like: NormaliseEdges(g.Edges, file.SAM) Error: not compatible with requested type Called from: runNormalisa

[Rcpp-devel] Help for call R function

2012-06-15 Thread bbo...@tin.it
e vector for example logpost(par) Logpost<-function(par) { .......} (in r code). How can i call teh logpost function into the inline rccp code . In the MHWG there is a difference f1-f0where fi=logpost(par1) e f0=logpost(par 2) for exemple. help me please to impleme

Re: [Rcpp-devel] [Rd] Performance of .C and .Call functions vs. native R code

2011-07-19 Thread Douglas Bates
ll line is nearly identical to >> the call to R operator '%*%'. Two data preparation lines for the .Call >> method create the overhead: >> >> A <- t(A) (~12sec, or 12usec per call) >> dim(A) <- dim(A)[1] * dim(A)[2] (~4sec, or 4usec per call) >> >&g

Re: [Rcpp-devel] calling R function triggers tryCatch() ???

2013-10-04 Thread Thomas Tse
cpp::export]] NumericVector rowApply1(NumericMatrix& x, const Function& FUN) {   int n = x.nrow();   NumericVector result = no_init(n);   for (int r = 0; r < n; r++) {     Language call(FUN, x(r, _)) ;     result[r] = as(call.fast_eval() );   }   return result; } // [[Rcpp::export]] N

Re: [Rcpp-devel] Rcpp syntactic sugar equivalent for R's optimize() function

2014-02-28 Thread Romain Francois
e stats package is quite high. I’d suggest : - reimplement clean c++ code as Dirk says - call the R function optimize form C++. Chances are the overhead of doing that is minimal and anecdotic compared to calling the objective function. - use something else as Dale says. > I am now using the approa

[Rcpp-devel] Memory not mapped

2014-02-20 Thread Hideyoshi Maeda
clock_limit, int init_pos) { // function takes in xts_obj_ (an xts object from R) and converts to a NumericMatrix Rcpp::NumericMatrix x(xts_obj_); // Get the index and call v DatetimeVector v(NumericVector(RObject(xts_obj_).attr("index"))); // The dimensions of rtn_xts are extra

Re: [Rcpp-devel] [Rcpp] How can i call a R function in Cpp source code?

2014-08-05 Thread PO SU
Vector x) { >| >|Function mean=Environment("package::base")["mean"]; >| >|return mean(x); >| >| } >| >| with the error "can't convert SEXP to double" >| >| How can i fix it ? Tks. >| > >| >With all due respect: >| > &

  1   2   3   4   5   6   7   8   9   10   >