Re: [Rcpp-devel] tracking volatile bug

2014-11-21 Thread Serguei Sokol
'norm' : Erreur : type 'char' indisponible dans 'eval' The wrong behavior is manifested in printing '">' It means that the string "1" was not wrapped correctly. The error messages (here in french but never mind) are just a consequence of th

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

2014-10-03 Thread Pierre Lafaye de Micheaux
you have an explanation on what goes wrong with what I have written on StackOverflow? Regards, Pierre L. Le 03/10/2014 12:49, Dirk Eddelbuettel a écrit : Oh, and I missed one call to a subordinate function. So add // [[Rcpp::export]] SEXP newCompQuant2(int n, int M, Rcpp::Function f) {

Re: [Rcpp-devel] How to efficiently remove some words from a big vector of strings.

2013-12-22 Thread Dirk Eddelbuettel
Please keep follow-up questions on the list where I am replying to now. On 22 December 2013 at 15:20, contact AG STUDY wrote: | Impressive!Thanks for this fast answer. | | |  error: no matching function for call to 'remove_if(std::vector | | >::iterator, std::vector | | >

[Rcpp-devel] Fwd: Calling R function in Rcpp returns compatibility issues

2017-07-27 Thread Sharat
Hi: I'm trying to call a R function (that compares strings) in Rcpp and return the result to make the comparisons run faster. Am a noob with Rcpp; so please bear. The input to the R function is a matrix of 2 columns. The error is: *Error in getGoing(product) : Not compatible with STRSXP:

Re: [Rcpp-devel] Connection between arma and rcpp

2013-01-29 Thread Kevin Ushey
In this case, I have to ask, 'why'? You want to use C++ to call R functions on R functions? This isn't going to give you any speed benefit, and it's not going to be any better than a base-R solution... if you want an 'apply' framework for matrices, you should ro

Re: [Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

2022-02-06 Thread Jeroen Ooms
On Sun, Feb 6, 2022 at 5:56 PM Dirk Eddelbuettel wrote: > > > On 6 February 2022 at 17:40, Jeroen Ooms wrote: > | We can try to take V8 out of the equation, and see what actually > | causes the change. V8 uses (and tests!) the Rcpp feature to call an R > | function from C++.

[Rcpp-devel] Template argument deduction with R objects

2018-10-13 Thread Vissarion Fisikopoulos
++ classes) and then call a function with those objects as parameters. My main issue is that I cannot extract from an R Class any type that can be used to parameterise a C++ templated function. Is there a standard way to do such an exposion within rcpp? Best, Vissarion

Re: [Rcpp-devel] Rcpp modules

2010-05-19 Thread Romain Francois
One thing perhaps I'd like opinions about is the use if the name "function" in : RCPP_MODULE(yada){ using namespace Rcpp ; function( "hello" , &hello ) ; } Boost.Python uses "def" but this is too pythonic for me. OTOH, having both Rcpp

Re: [Rcpp-devel] Using formula

2024-09-26 Thread Denis Haine
on' not found. Named("link", "log") Named("make.link", "log") These last two do not cause an error, but they give the default logit link (as if the Named was not evaluated?). Thanks, Denis Le 2024-09-04 16:24, Dirk Eddelbuettel a écrit : On 4 Sept

Re: [Rcpp-devel] One main needs to call a few other functions

2011-10-20 Thread Silkworth,David J.
>> I have need for a few c++ functions. (One main needs to call a few other functions.) At this point, I don't need separate classes, just the ability to have multiple functions. (Coding up several separate R functions using Inline would be ineffecient as the data would need to pas

Re: [Rcpp-devel] Rcpp "version" of R's match function

2012-11-14 Thread Søren Højsgaard
ber 2012 00:01 To: rcpp-devel@lists.r-forge.r-project.org Subject: Re: [Rcpp-devel] Rcpp "version" of R's match function Le 14/11/12 23:48, Søren Højsgaard a écrit : > Dear all, > > I need to call R's match function from a c++ program so I can do > Rcpp::Function R_m

[Rcpp-devel] R.e.: Problems with rlnorm

2011-05-29 Thread Christian Gunning
already pointed this out). Below is an example that includes by-column assignment. Also, unless you need to reset the seed mid-function-call, RNGScope grabs the seed from R, so you can use a regular set.seed call. So, the return value of the following is identical to that of your example: requir

[Rcpp-devel] Strange behavior with boost::program_options

2016-07-05 Thread Watal M. Iwasaki
Hi all, I have been trying to make an R function to call my C++ simulation program in this way: ```c++ // [[Rcpp::plugins(cpp14)]] #include #include // [[Rcpp::export]] std::string run_simulation(Rcpp::CharacterVector args=Rcpp::CharacterVector::create()) { auto vs_args = Rcpp::as>(a

Re: [Rcpp-devel] Segfaults

2012-01-05 Thread Steve Lianoglou
nline function and I never >> call the inline function directly anywhere else. The job of the thin R >> wrapper function is to sanity check and/or coerce the vars to the >> correct type before they are past to the inline'd function to avoid >> the segfault. > (I'

Re: [Rcpp-devel] named and default arguments in exposed C++ classes

2014-03-06 Thread Andreas Prescher
aker=Environment::Rcpp_namespace()[ "cpp_object_maker"]; return maker ( typeid(Foo).name() , exPointer ); } int bar(Foo* f,int x, int y) {return f->bar(x,y);} RCPP_MODULE(PsiMin) { function( "createFoo", &createFoo); function( "bar", &bar,

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

2014-02-05 Thread Antonio Piccolboni
t;) rcpp.serialize = cppFunction(code="RObject my_serialize(RObject x){Function r_serialize(\"serialize\"); return r_serialize(x, R_NilValue);}") rcpp.serialize(10) [1] 58 0a 00 00 00 02 00 03 00 02 00 02 03 00 00 00 00 0e 00 00 00 01 40 24 00 00 00 00 00 00 # easy things wor

[Rcpp-devel] exposing a C++ function to RInside

2012-08-18 Thread Stephen J. Barr
Hello, I have a quick design question. I am working on a program that uses RInside and RcppEigen, and I want to expose a function back to R. Specifically, I have a C++ function with the following signature: double nll_singleton( const VectorXd& theta, const MatrixXd& ua,

[Rcpp-devel] Rcpp RMpfr mpreal to mpfr wrapping

2012-11-18 Thread Thell Fowler
ze(); i++) { d[2*i] = (int) RIGHT_HALF(pv->_mpfr_d[i]); d[2*i+1]= (int) (pv->_mpfr_d[i] >> 32); } } vS4.slot("d") = wrap( d ); S4 ans("mpfr"); ans.slot(".Data") = List::create( wrap(vS4) ); return wrap( ans ); //

[Rcpp-devel] RInside: C/C++ function(s) passed to R?

2019-11-08 Thread LEVRA-JUILLET William
es RInside to call R from our code. Let's say I have a C++ function implemented in my project, and I want to pass that c++ function to R so it can be "used" as a R function (typically passed as argument to optim/optimize) I couldn't find a way to do that using RInside.

[Rcpp-devel] Fwd: Re: Making objects in the C++ "side" persistent

2014-06-15 Thread Martin Jakt
environment contains a set of external pointers which are used by the methods of the S4 object created. The environment also contains refMethodDef objects for external functions that have been called at least once. Which sort of brings me to my question: If I have an object called ds1, which

Re: [Rcpp-devel] Request for help with compiling Rcpp example

2011-10-13 Thread Dirk Eddelbuettel
ome to C++ Programming" << endl; | + }' | >  | > fx <- cxxfunction(src,plugin = "Rcpp",verbose=T) PBKAC -- wrong call of cxxfunction(). You can see below how the generated code does *not* include your actual function. The correct idiom is fx <- cxxfunct

Re: [Rcpp-devel] Memory not mapped

2014-02-20 Thread Kevin Ushey
ing in simple statements at the end, it no > longer works > > here is the full test.cpp that WORKS > > > #include > using namespace Rcpp; > > // [[Rcpp::export]] > List entryexitclock( SEXP xts_obj_,int ent_col, int exit_col, double > clock_limit, int init_pos) { &g

Re: [Rcpp-devel] Fwd: Calling R function in Rcpp returns compatibility issues

2017-07-27 Thread Balamuta, James Joseph
Subject: [Rcpp-devel] Fwd: Calling R function in Rcpp returns compatibility issues Hi: I'm trying to call a R function (that compares strings) in Rcpp and return the result to make the comparisons run faster. Am a noob with Rcpp; so please bear. The input to the R function is a matrix

Re: [Rcpp-devel] Rcpp RMpfr mpreal to mpfr wrapping

2012-11-18 Thread Romain Francois
) = wrap( exp ); for(i=0; i < d.size(); i++) { d[2*i] = (int) RIGHT_HALF(pv->_mpfr_d[i]); d[2*i+1]= (int) (pv->_mpfr_d[i] >> 32); } } vS4.slot("d") = wrap( d ); S4 ans("mpfr"); ans.slot(".Data")

Re: [Rcpp-devel] Rcpp modules

2010-05-20 Thread Romain Francois
;bar ) ; |> function( "foo" ,&foo ) ; |> function( "bla" ,&bla ) ; |> function( "bla1" ,&bla1 ) ; |> function( "bla2" ,&bla2 ) ; |> |> } |> |> All the magic happens because the compiler knows how to distinguish the |&

Re: [Rcpp-devel] Exporting rcpp-based function into parLapply workers in an R package

2021-05-14 Thread Balamuta, James Joseph
;rcpp-devel@lists.r-forge.r-project.org" Subject: [Rcpp-devel] Exporting rcpp-based function into parLapply workers in an R package Dear Rcpp developers: Thanks for developing and maintaining the Rcpp package. I wrote a function in Rcpp. It is available throughout the package and works as

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

2013-10-01 Thread Renaud Gaujoux
pp.h:50:0," [36] " from rcpp_octave.h:25," [37] " from rcpp_octave.cpp:21:" [38] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:156:21: error: 'result_type' does not name a type" [39] "C:/R/R-3.0.2/libra

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

2013-10-14 Thread Romain Francois
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]] NumericVector rowApply2(

Re: [Rcpp-devel] RInside: C/C++ function(s) passed to R?

2019-11-08 Thread Iñaki Ucar
nteract our C++ project with R. > > > > I’ve seen the samples to get/set data (matrix, dataframes, etc) to/from R > > and it builds/works fine. > > > > (Using gcc/mingw compiler from RTools on Windows) > > > > > > > > My questions is about functions

Re: [Rcpp-devel] About calling C/C++ functions in R

2010-06-16 Thread Romain Francois
ho ; return result.c_str() ; } int main(int argc, char *argv[]) { // create an embedded R instance RInside R(argc, argv); // expose the "hello" function in the global environment R["hello"] = Rcpp::InternalFunction( &hello ) ; // call it a

[Rcpp-devel] Patch to Rcpp-quickref: R/C++ interface

2011-01-02 Thread Christian Gunning
R, create a package shell. For details, see the "Writing R Extensions" manual. + +Rcpp.package.skeleton("myPackage") + +## Add R code to pkg R/ directory. Call C++ function. Do type-checking in R. + +myfunR = function(Rx, Ry) { +ret = .Call("myCfun", Rx, Ry, +

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

2014-10-04 Thread Pierre Lafaye de Micheaux
| > 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 <-

[Rcpp-devel] Fwd: Rcpp and rpy2

2011-08-12 Thread Jonas Rauch
would like to call a very complex R function from python. My function depends on code implemented with Rcpp. When I try to load Rcpp from python via import rpy2.robjects as robjects robjects.r('library(Rcpp)') I get the following: Error in dyn.load(file, DLLpath = DLLpath, ...) : unab

Re: [Rcpp-devel] Rcpp::stop() equivalent of base::stop(..., call.=FALSE)

2018-03-05 Thread Michael Weylandt
t;- as.numeric(x) > } > > do.call(internal_function_name, list(x)) > } > > add2(1:5) > ``` > > > > > On Mon, Mar 5, 2018 at 4:35 PM, Michael Weylandt > wrote: >> >> Hi, >> >> Is there any (easy) way to get Rcpp::stop() to behave li

Re: [Rcpp-devel] How to elevate privilege from within Rcpp?

2015-03-15 Thread Bhaskar V. Karambelkar
I need to call a 3rd party library function with root privileges. > | I'm not sure how to accomplish this from within Rcpp. > > I dont think you can ... > > | If I was writing an executable, I could call seteuid to elevate > privileges > | before calling the extern

Re: [Rcpp-devel] Call by reference

2015-07-29 Thread Hao Ye
| data frames with over a million rows and hundreds of columns. It is more > | efficient to operate on such a data frame directly, as opposed to copying it > | into and out of a function. In other words, I want to be *not* like R, > which is > | why I am interested in utilizing C++, wh

[Rcpp-devel] R Session Aborted when calling C++

2020-10-28 Thread Alexander Ilich
_textures_helper(rq = as.matrix(rq), w = c(17,17), n_levels = 4, shift = c(-1,1)) #Internal C++ function called within the R function glcm_textures #From playing around with it and commenting out code blocks, C_glcm_textures_helper seems to crash at the call to C_make_glcm #Create a new datase

Re: [Rcpp-devel] Error when calling `qchisq()`.

2013-07-05 Thread Simon Zehnder
Hi Xiao, I assume, that you have to use the function with its namespace R::qchisq(). The 'using namespace Rcpp;' command does not include the namespace R in which the function qchisq is defined. Best Simon On Jul 5, 2013, at 6:22 PM, Xiao He wrote: > Hi, > > I t

Re: [Rcpp-devel] Method with default params using RCPP_MODULE

2016-10-28 Thread Sergio Bra
Thanks for your useful comments, I am trying something like this in a R file (I have changed the name of my c++ method compared with the example above, now is called myMethodCpp in order to avoid conflicts with the R name's function): myClass$myMethod <- function(param1, par

[Rcpp-devel] Fwd: Looping over the parameters of a function

2014-04-08 Thread Petre Caraiani
on and the main program. I can call this > program > | from R. What I am interested in is looping over the parameters of the > defined > | function. For example, passing an array a to the C program and computing > the > | root of the function: (x*x-a[i]/2) for each entry in vector a

Re: [Rcpp-devel] Inline and Parallel computing

2012-04-19 Thread Dirk Eddelbuettel
tion | sillyscr <- ' | int x = as(i); | double y = 5.6; | NumericVector j(1); | j[0] = x + y; | | return j; | ' | silly <- cxxfunction(signature(i = "int"), body = sillyscr, plugin = "Rcpp") | silly(1) # Works! | | # Equivalent function in R to m

Re: [Rcpp-devel] how to get data from old dll which returns Microsoft variant structure

2020-12-02 Thread Dirk Eddelbuettel
Shreedhar, On 2 December 2020 at 15:48, Tase, Shreedhar wrote: | Hi | I have DLL which has function which returns 2D array flattened to 1-dimentional array of Microsoft variant type structure. I am able to call that function using Rcpp; I want to take that data in R. |I

Re: [Rcpp-devel] Newbie question: RInside from within a Inline/Rcpp cxxfunction

2012-09-28 Thread Dirk Eddelbuettel
f the R language too. Is it possible for me to have my cxxfunction instantiate an object of class RInline within the C++ code? I guess what I'm getting at is, can I get R to call on a C++ function which in turn calls upon R code? | | I've looked at plenty of examples of code that use

Re: [Rcpp-devel] replacing a splines ns() call with other Rcpp attached library function

2012-06-29 Thread Silkworth,David J.
for code in the middle of a double loop to go to R just to get all the "boiler-plate" of the R code in ns(). We need to know how to call spline_basis directly with confidence. I'm just looking to get one function to work for one problem. No thought at this time of actually att

[Rcpp-devel] Rcpp modules

2010-05-19 Thread Romain Francois
la1 ) ; function( "bla2" , &bla2 ) ; } All the magic happens because the compiler knows how to distinguish the type of each function pointer and we manage to intercept this information through C++ templates. The only price to pay is the d

Re: [Rcpp-devel] Timings for a program

2017-01-06 Thread Christian Gunning
piled language. What Martyn said is exactly correct - it's your responsibility to understand the difference between an interpreted language like R and a compiled language like C++. Some rules of thumb: * In both R and C++, avoid unnecessary memory allocations. * In R, minimize the number of dist

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
Dirk | > set.seed(42) | > x=rnorm(1e5) | > callFunction | function (x, f) | .Primitive(".Call")(, x, f) | > callFunction(x, fivenum) | terminate called after throwing an instance of 'Rcpp::not_compatible' | what(): cannot convert to function | Abort trap: 6 | | --

Re: [Rcpp-devel] Rcpp modules and parsing an object back and forth between R & C++

2013-02-20 Thread Romain Francois
Rcpp::XPtr xp( ptr, true ) ; Function maker = Environment::Rcpp_namespace()[ "cpp_object_maker"] ; return maker( typeid(Class).name() , xp ) ; } } This essentially calls the R function Rcpp:::cpp_object_maker cpp_object_maker <- function(ty

Re: [Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

2022-02-06 Thread Kevin Ushey
t 17:40, Jeroen Ooms wrote: > > | We can try to take V8 out of the equation, and see what actually > > | causes the change. V8 uses (and tests!) the Rcpp feature to call an R > > | function from C++. This behaves quite differently when using > > | RCPP_UNWIND_PROTECT. > > | &g

Re: [Rcpp-devel] RcppArmadillo solve function, dyn.load error

2012-05-06 Thread Dirk Eddelbuettel
th/libs/aynSVMpath.so: undefined symbol: | dtrtrs_ | | | If I change 3rd and 4th lines of the 'solveKstar' function to: | |   vec solution; |         

[Rcpp-devel] inplace modification more affect other varibles

2014-10-21 Thread Chenliang Xu
ed filed = 0 so is safe to modify inplace. Then, we have to call the function as `stl_sort_inplace(inplace(a))`, which seems odd but is also informative. It shows clearly that we are breaking the pass-by-value rule in R. ```cpp #include using namespace Rcpp; // [[Rcpp::export]] void s

Re: [Rcpp-devel] named and default arguments in exposed C++ classes

2014-03-05 Thread Dirk Eddelbuettel
from R | > f <- new(Foo) | > f$bar(x = 1) => 3 | > f$bar(x = 1, y = 1) => 2 | | I only can call my methods like this: | > f$bar(3,4) => 7 | | Is there a workaround to make named/default | arguments working when using classes? | | E.g. make some "mix" wit

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

2013-10-11 Thread Hadley Wickham
& 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]] >

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

2013-10-11 Thread Hadley Wickham
> } >> >> // [[Rcpp::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(FU

Re: [Rcpp-devel] ColDatum constructors memory safety

2010-03-18 Thread Dirk Eddelbuettel
src <- 'std::vector colDatumVector(10); return R_NilValue;'; funx <- cfunction(signature(), src, Rcpp=TRUE) checkEquals(funx(), NULL, msg = "RcppColDatum.vector") } R> test.ColDatum.vector <- function() { + src <- 'std::vector colDatumVector(10

Re: [Rcpp-devel] Misunderstanding about sugar

2011-10-20 Thread Dirk Eddelbuettel
ne) | > | > xorig <- c(1, -2, 3, -4, 5, -6, 7) | > | > code <- ' | + NumericVector x(xs); | + return sapply( x, abs ); | + ' | > | > xabs <- cxxfunction(signature(xs="numeric"), | + plugin="Rcpp", | +

Re: [Rcpp-devel] Persistence of C++ changes in R.

2010-12-23 Thread Douglas Bates
gt; to >>> be modified, given that I had assign 100.0 to xD[1,1] in C++? >> >> Well when I call cxxfunction on that code I get a warning.  Did you? >> >> The warning tells me that I am indexing xD as a one-dimensional array >> and that leads me

Re: [Rcpp-devel] Struggling with cppFunction() and clusterExport()

2013-09-26 Thread Romain Francois
crit : Dear Rcpp developers, I'm trying to parallelize some of my algorithms but I have encountered the following problem: # I have a cppFunction cppFunction(' double inner_Cpp(double a){ return 1; } ') # And an R wrapper around it wrapper_R<- function(input) { inner_Cpp

Re: [Rcpp-devel] Using complex numbers in a C program called by R

2016-01-04 Thread Baptiste Auguie
complex >> numbers >> | (create some, addition, multiplication, division, modulus, etc) >> | directly in a C code that is called from R (using the .C interface). >> | Note that these complex numbers might not come from R but could be >> created >>

[Rcpp-devel] Problem exposing inherited member function of derived class to R through RCPP_MODULE

2013-09-24 Thread Luke.Domanski
A_derived::fun1) ; } test2.cpp: In function 'void _rcpp_module_testing_init()': test2.cpp:33:37: error: no matching function for call to 'Rcpp::class_::field(const char [5], double A::*)' test2.cpp:33:37: note: candidate is: C:/.../R/win-library/3.0/Rcpp/include/Rcpp/module/M

Re: [Rcpp-devel] passing function

2011-01-26 Thread Dirk Eddelbuettel
om the | > source code submitted via variable 'cpp'. | | I think the question was about the line 'Function f(fun)'. | | And the answer is that 'fun' is the second argument of the C++ function, and is an SEXP for the R function passed in. (See the 'signature

Re: [Rcpp-devel] Broken wrapper code using .Call in R 3.0

2013-05-14 Thread Dirk Eddelbuettel
error does not appear until example code in the man pages is run for | functions including .Call() for my RcppArmadillo code. | The Error report indicates that the function identified by its string name is | not available for .Call() | | My NAMESPACE still contains the original lines from

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

2013-10-01 Thread Romain Francois
from rcpp_octave.h:25," [37] " from rcpp_octave.cpp:21:" [38] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:156:21: error: 'result_type' does not name a type" [39] "C:/R/R-3.0.2/library/Rcpp/include/Rcpp/Language.h:161:

[Rcpp-devel] Linking code in src/ subfolders

2015-03-10 Thread Balamuta, James Joseph
tps://github.com/coatless/header_cpp_subdir_code/blob/master/src/Makevars.win ) Herein lies the issues: 1.Any files I've written in the subdirectories are no longer exported to RcppExport.cpp even though they have a // [[Rcpp::export]] tag preceding the function declaration. 2.

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

2013-10-01 Thread Dirk Eddelbuettel
gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/include/_mingw.h:244:0: | note: this is the location of the previous definition" | [35] "In file included from | C:/R/R-3.0.2/library/Rcpp/include/Rcpp.h:50:0," | [36] " from rcpp_octave.h:25," | [

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

2013-07-27 Thread Tal Galili
Hi Romain, Originally I hoped to be able to "get around" writing various functions in C++, by having Rcpp wrap an R function. But after Krzysztof explanation, and yours, I realized it would not offer any gain (due to the copying of objects all around). In which case, I am back to th

Re: [Rcpp-devel] Installation Problem

2011-03-23 Thread Dirk Eddelbuettel
Hi Sean, On 23 March 2011 at 00:20, Sean Robert McGuffee wrote: | Hi, | I’m new to using C++ inside of R. I got a test program to work, so | it’s time for me to attach some function to it. I seem to be having | some issues though. I wonder if anyone out there can help me | understand the results

Re: [Rcpp-devel] Persistence of C++ changes in R.

2010-12-22 Thread Douglas Bates
, not xD[1,1] > 2. Why does the change to the object D persist when we call the object > again? This looks like D has been passed by reference and is therefore > affected by what happened within the function. However, this is not the > expected behaviour for an R function. What's

Re: [Rcpp-devel] Problem exposing inherited member function of derived class to R through RCPP_MODULE

2013-09-25 Thread Luke.Domanski
l@lists.r-forge.r-project.org > Subject: Re: [Rcpp-devel] Problem exposing inherited member function of > derived class to R through RCPP_MODULE > > Hello, > > Due to the way modules are currently implemented, what goes in .field > and .method must be member of the actual clas

Re: [Rcpp-devel] Exporting rcpp-based function into parLapply workers in an R package

2021-05-14 Thread Naeem Khoshnevis
*Friday, May 14, 2021 at 11:49 AM > *To: *"rcpp-devel@lists.r-forge.r-project.org" < > rcpp-devel@lists.r-forge.r-project.org> > *Subject: *[Rcpp-devel] Exporting rcpp-based function into parLapply > workers in an R package > > > > Dear Rcpp developers: > > T

Re: [Rcpp-devel] pnorm/qnorm?

2012-09-07 Thread Dirk Eddelbuettel
ot;, arg2="numeric"), str, | plugin="Rcpp") | | #check2(0.5, 0.5) | | 33: return wrap(qnorm(a, b, 1.)); | 34: | 35: END_RCPP | 36: } | 37: | 38: | Error in compileCode(f, code, language = language, verbose = verbose) : |Compilation ERROR, function(s)/method(s) not c

Re: [Rcpp-devel] RCPP_USE_UNWIND_PROTECT by default

2022-02-06 Thread Kevin Ushey
:18 AM Jeroen Ooms wrote: > >> On Sun, Feb 6, 2022 at 5:56 PM Dirk Eddelbuettel wrote: >> > >> > >> > On 6 February 2022 at 17:40, Jeroen Ooms wrote: >> > | We can try to take V8 out of the equation, and see what actually >> > | causes the ch

Re: [Rcpp-devel] Building shared libs with Rcpp does not work as before after Debian update

2014-03-18 Thread Dirk Eddelbuettel
On 18 March 2014 at 11:43, Andreas Recke wrote: | * in R console | | >dyn.load("test.so") | >.Call("norm_wrapper", x_=2, y_=3) | | and I get the error message, that function "dataptr" is not provided by | package "Rcpp&quo

Re: [Rcpp-devel] RcppArmadillo Memory Leak?

2013-11-18 Thread Dirk Eddelbuettel
each call and doesn't decrease after the | garbage collection. | | Am I doing something wrong? The sparse() function modifies an object. R uses copy on write, so by modifying the matrix A, you are creating a new one. That is normal. You then ignore the returned object but not assigning the

Re: [Rcpp-devel] Rcpp/C++ serialization of R objects?

2013-10-29 Thread Romain Francois
Le 29/10/2013 16:24, Rodney Sparapani a écrit : Hi Gang: I have been through the docs, and if this is answered, then I missed it. Is there a recommended way to serialize an R object with Rcpp? Not at the moment. It is pretty easy though to make an R call to saveRDS using Function

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

2011-05-14 Thread Christian Gunning
t 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 integer vector. 2. I find it easiest to sample indices rather then elements of the

[Rcpp-devel] rsession memory consumption blows up

2015-06-23 Thread Fabio Tordini
Hello, I encountered this problem while working on my Rcpp package. I don't know if it can be related to Rcpp, but I post it here looking for some advices. I'll try to make myself as clear as possible: from an R function in my Rcpp package I call a C++ function where huge datas

Re: [Rcpp-devel] Stack imbalance warning when using Rcpp and OpenMP

2011-07-27 Thread Dirk Eddelbuettel
directly (same function), it works. But if I call another function from the parallelized loop, and do some Rcpp work in that function, that's when I get problems. Yes, you cannot 'multithread' R just like that. R is single-threaded and (AFAIK) not reentrant. Just because you&#x

[Rcpp-devel] function within a function

2012-05-02 Thread Marie Auger-Methe
em work. 1. Include a call to the header of function f1 in the .cpp file of function f2 or include both functions in one set of header and .cpp files? But I'm not sure how to do this properly. 2. Using Rcpp Module? But from what I understand the modules mainly help to remove the .Call in

Re: [Rcpp-devel] Fwd: Calling R function in Rcpp returns compatibility issues

2017-07-27 Thread Sharat
devel] Fwd: Calling R function in Rcpp returns > compatibility issues > > > > Hi: > > > > I'm trying to call a R function (that compares strings) in Rcpp and return > the result to make the comparisons run faster. Am a noob with Rcpp; so > please bear. The input to

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

2016-08-03 Thread George Vega Yon
1.0 1 1 So, on average, while Rcpp::Function took ~7 times the R call took, my implementation took ~1.3 times. To be sure I was not breaking anything I ran the example using valgrind and there is no memory leak. The source code for the test follows: example_calling_r_functions.cpp

Re: [Rcpp-devel] Parallel R::bessel_k function in Rcpp

2016-03-23 Thread Dirk Eddelbuettel
On 24 March 2016 at 01:02, Hoang Nguyen wrote: | Hi, | I am working with Rcpp and need to call function bessel_k from R::bessel_k in | parallel. I got usually crash in Rstudio, and still not find out which is the | mistake You _cannot call back to R_ from parallel code. | Here is my code in R

Re: [Rcpp-devel] R Session Aborted when calling C++

2020-10-28 Thread Alexander Ilich
, quantization = > "none", shift=c(-1,1)) #R function > test4<- GLCMTextures:::C_glcm_textures_helper(rq = as.matrix(rq), w = > c(17,17), n_levels = 4, shift = c(-1,1)) #Internal C++ function called > within the R function glcm_textures > > #From playing around with i

Re: [Rcpp-devel] What is the best practice to expose a C st ructure from 3rd party library into R?

2013-07-23 Thread Wush Wu
--- > // for now, single worker function > extern "C" SEXP execRedisCommand(SEXP p) { > Redis redis; > std::string txt = Rcpp::as(p); > std::string res = redis.execCommand(txt); > return Rcpp::wrap(res); > } > > ----

Re: [Rcpp-devel] pnorm/qnorm?

2012-09-07 Thread Rodney Sparapani
verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! file33b64e743def.cpp: In function 'SEXPREC* file33b64e743def(SEXPREC*, SEXPREC*)': file33b64e743def.cpp:33: error: no matching function for call to 'qnorm5(double&, double&, double)&#x

Re: [Rcpp-devel] Error when calling `qchisq()`.

2013-07-05 Thread Xiao He
Thanks. This solves the problem! Sent from my iPhone On Jul 5, 2013, at 9:47 AM, Simon Zehnder wrote: > Hi Xiao, > > I assume, that you have to use the function with its namespace R::qchisq(). > The 'using namespace Rcpp;' command does not include the namespace R in

[Rcpp-devel] Struggling with cppFunction() and clusterExport()

2013-09-26 Thread Matteo Fasiolo
Dear Rcpp developers, I'm trying to parallelize some of my algorithms but I have encountered the following problem: # I have a cppFunction cppFunction(' double inner_Cpp(double a){ return 1; } ') # And an R wrapper around it wrapper_R<- function(input) { inner_Cpp(input)

Re: [Rcpp-devel] inplace modification more affect other varibles

2014-10-22 Thread Gabor Grothendieck
g in R. A > possible fix is adding a function `inplace` to R, which ensure the returned > variable has named filed = 0 so is safe to modify inplace. Then, we have to > call the function as `stl_sort_inplace(inplace(a))`, which seems odd but is > also informative. It shows clearly that

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

2014-02-05 Thread Dirk Eddelbuettel
| but if I try from C++ the call gets evaluated | |  library("Rcpp") | |  rcpp.serialize = cppFunction(code="RObject my_serialize(RObject x){Function | r_serialize(\"serialize\"); return r_serialize(x, R_NilValue);}") | |  rcpp.serialize(10) |  [1] 58 0a 00 00 00 02 0

[Rcpp-devel] Fwd: Request for help with compiling Rcpp example

2011-10-14 Thread Jian Kang
| Hi, Dirk, | | Sorry to disturb you again. | | Actually, I am also very interested in how to call back the R commands in | 'cxxfunction'. Do you have some examples or tutorial about this? Please keep questions on the mailing list. Dirk | | Thank you very much. | | Best regards

Re: [Rcpp-devel] RInside and MPI master slave model proper usage

2013-01-19 Thread Nicholas Pezolano
Maybe I did not describe my question/problem clearly, I've seen the examples and you would call RInside R(int argc, int argv); after int main and mpi_init, and all nodes should have an embedded R instance. However the problem with using MPI and RInside in the above master slave model i

Re: [Rcpp-devel] Making R package with Rcpp Issue: Found '_ZSt4cout'

2015-08-30 Thread Dirk Eddelbuettel
d the following code to be able to call | upon that function:  | | #include | #include | //[[Rcpp::depends(RcppArmadillo)]] | | | After I created another function that avoided my needing to call upon the | function that required this, then going back to putting the usual stuff at the | top of my .cpp

Re: [Rcpp-devel] Request for help with compiling Rcpp example

2011-10-13 Thread Dirk Eddelbuettel
dd = TRUE) | | stopifnot(do.call(".C", list("foo",0L))[[1]] == 1L) | TRUE | } | | R <- function(options, path = tempdir()) { | r_path <- shQuote(file.path(R.home("bin"), "R")) | in_dir(path, system_check(paste(r_path, options))) | } | | syste

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

2012-08-28 Thread Davor Cubranic
size since using a 3x2 matrix would time almost nothing but R function call, and am using 'benchmark', rather than 'microbenchmark'. These results are what I would have expected: all three methods are within a few percent of each other. The direct .Call is the fastest, then

Re: [Rcpp-devel] Trouble passing arguments to R functions that have been passed in (maybe)

2012-09-10 Thread Anthony Lee
On 10/09/12 22:05, Dirk Eddelbuettel wrote: I didn't have a lot of time for your post but I suspect your design is broken if you plan to call an R function in each itereation of a C++ loop. Just because you can does not mean you should. Dirk In fact, there are some good reasons for

Re: [Rcpp-devel] Problem exposing inherited member function of derived class to R through RCPP_MODULE

2013-09-24 Thread Romain Francois
t;C:/PROGRA~1/R/R-30~1.1/include" -DNDEBUG -I"C:/.../R/win-library/3.0/Rcpp/include" -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -mtune=core2 -c test2.cpp -o test2.o test2.cpp: In function 'void _rcpp_module_testing_init()': test2.cpp:33:37:

Re: [Rcpp-devel] named and default arguments in exposed C++ classes

2014-03-06 Thread Dirk Eddelbuettel
| function( "createFoo", &createFoo); | function( "bar", &bar, List::create(_["f"], _["x"], _["y"] = 2)); | } | in R: | > f <- createFoo() | > bar(f = f, x = 3); | | Is this OK, are there some memory issues I

[Rcpp-devel] Segfaults in custom code and test.NumericMatrix.cumsum

2012-02-07 Thread Michael Shvartsman
egfault. Any ideas of where else to look? Thanks, Mike Shvartsman. == The unitTest segfault === Executing test function test.NumericMatrix.cumsum ... *** caught segfault *** address 0x0, cause 'unknown' Traceback: 1: .Primitive(".Call"

[Rcpp-devel] Improving the speed of a custom function that fixes broken encoding

2020-07-19 Thread Casper Crause
this function is a real concern when the datasets get over 500 000 rows. I've adapted the function to conditionally modify only broken text with ifelse statements. I *really* want to speed up this function using Rcpp, but there are two problems 1. I tried researching how to call python functi

Re: [Rcpp-devel] problem with sample() implemented in Rcpp/RcppArmadillo

2012-11-04 Thread Christian Gunning
y easier to reply to.) Today I learned that revsort is an exported function from the R API, and is therefore in the bible (6:10): http://cran.r-project.org/doc/manuals/R-exts.html#Utility-functions revsort just does the following two operations in a single function call (via scary pointer mag

<    1   2   3   4   5   6   7   8   9   10   >