[Rcpp-devel] Code De-bugging

2010-12-22 Thread Savitsky, Terrance
My RcppArmadillo code is structured with a .cpp function that calls a group of enabling .cpp functions. The .cpp function returns SEXP arguments and is wrapped in the macros BEGIN_RCPP, END_RCPP to promote C++ errors to R. The group of other functions called are structured as void return (passing

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

2010-12-22 Thread Dirk Eddelbuettel
On 22 December 2010 at 18:08, Cedric Ginestet wrote: | Dear Rcpp Experts, | | I have encountered two issues when modifying an object within C++ function. See | the code below: | | ## | library(inline); library(Rcpp) | D <- matrix(rnorm(4),2,2) | src3 <- '

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

2010-12-22 Thread Douglas Bates
On Wed, Dec 22, 2010 at 12:08 PM, Cedric Ginestet wrote: > Dear Rcpp Experts, > > I have encountered two issues when modifying an object within C++ function. > See the code below: > > ## > library(inline); library(Rcpp) > D <- matrix(rnorm(4),2,2) > src3 <-

Re: [Rcpp-devel] C++ Throwing Exception.

2010-12-22 Thread Dirk Eddelbuettel
On 22 December 2010 at 10:40, Andrew Redd wrote: | To chime in about Romain's comment about recognizing more types.  I would love | a more robust exception handling.  I think I already mentioned that but | sometimes throwing a std::exception can be very expensive.  something a little | bit more ro

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

2010-12-22 Thread Cedric Ginestet
Dear Rcpp Experts, I have encountered two issues when modifying an object within C++ function. See the code below: ## library(inline); library(Rcpp) D <- matrix(rnorm(4),2,2) src3 <- ' NumericMatrix xD(D); xD[1,1] = 100.0; return xD; ' passRef <- cxx

Re: [Rcpp-devel] C++ Throwing Exception.

2010-12-22 Thread Andrew Redd
To chime in about Romain's comment about recognizing more types. I would love a more robust exception handling. I think I already mentioned that but sometimes throwing a std::exception can be very expensive. something a little bit more robust would be very helpful. For example, with the discus

Re: [Rcpp-devel] Regression in conversion from NumericVector to ComplexVector?

2010-12-22 Thread Dirk Eddelbuettel
On 22 December 2010 at 09:18, Christian Gunning wrote: | > test1 = cxxfunction(signature(vec='complex'), ' | >            ComplexVector x(vec) ; | >                int nn = x.size(); | >                for( int i=0; i                    x[i].r = x[i].r*2 ; | >                    x[i].i = x[i]

Re: [Rcpp-devel] Regression in conversion from NumericVector to ComplexVector?

2010-12-22 Thread Christian Gunning
> test1 = cxxfunction(signature(vec='complex'), ' >            ComplexVector x(vec) ; >                int nn = x.size(); >                for( int i=0; i                    x[i].r = x[i].r*2 ; >                    x[i].i = x[i].i*2 ; >                } >                return x ; > ', plugi

Re: [Rcpp-devel] sugar performance

2010-12-22 Thread Douglas Bates
On Wed, Dec 22, 2010 at 5:33 AM, wrote: >  Hello, > > Following Gabor's thread yesterday, I looked into R source code and figure > that we don't need to test for NA when using numeric vector. See this: > > require(inline) > require(Rcpp) > > pl <- cxxfunction( , ' >    return List::create( >    

Re: [Rcpp-devel] Regression in conversion from NumericVector to ComplexVector?

2010-12-22 Thread Dirk Eddelbuettel
On 21 December 2010 at 22:23, Christian Gunning wrote: | A few unit tests of instantiating a ComplexVector are attached. Thank you! Now applied as rev 2811. Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com ___ Rcpp-devel ma

Re: [Rcpp-devel] C++ Throwing Exception.

2010-12-22 Thread Dirk Eddelbuettel
On 22 December 2010 at 11:56, Cedric Ginestet wrote: [...] | throw("Matrix Index is lower than 0."); [...] | How can I modify my code in order to get the reason for the exception | printed within R. By passing a exception class that inherits from std::exception, see a C++ reference an

Re: [Rcpp-devel] C++ Throwing Exception.

2010-12-22 Thread romain
Hello, That is because you are not throwing an exception, but a "const char*" and END_RCPP does not recognize this type. Maybe it should. You can either create your own exception class or use one from the standard set: http://cplusplus.com/reference/std/exception/exception/ Romain Le mer

Re: [Rcpp-devel] sugar performance

2010-12-22 Thread romain
Le mer 22/12/10 13:02, "Gabor Grothendieck" ggrothendi...@gmail.com a écrit: > On Wed, Dec 22, 2010 at 6:33 AM, i...@r-enthusiasts.com> wrote: > Also, I'm trying to write the looping internally in > order to get a better comparison. With the attached file, I > get: > The attachment does not see

Re: [Rcpp-devel] sugar performance

2010-12-22 Thread Gabor Grothendieck
On Wed, Dec 22, 2010 at 6:33 AM, wrote: > Also, I'm trying to write the looping internally in order to get a better > comparison. With the attached file, I get: The attachment does not seem to have made it through. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-

Re: [Rcpp-devel] C++ Throwing Exception.

2010-12-22 Thread Cedric Ginestet
Dear Rcpp experts, I have got another problem with the throw of exception in C++ channelled into R. Apologies but these codes are not reproducible: I didn't succeed to use the BEGIN_RCPP ... END_RCPP commands with the inline-package. Help regarding this would be also welcomed. #

[Rcpp-devel] sugar performance

2010-12-22 Thread romain
Hello, Following Gabor's thread yesterday, I looked into R source code and figure that we don't need to test for NA when using numeric vector. See this: require(inline) require(Rcpp) pl <- cxxfunction( , ' return List::create( NA_REAL + NA_REAL, NA_REAL + 1.0, 1

Re: [Rcpp-devel] SUGAR: Vector-Scalar operations

2010-12-22 Thread Cedric Ginestet
Perfect. You were correct. It was just to do with my compiler. It worked. For future reference, my compiler's version is: gcc 4.4.3 Cheers, Cedric On 22/12/10 10:49, rom...@r-enthusiasts.com wrote: Hmm. It works for me : romain@ /tmp $ Rscript scalar.R Le chargement a nécessité le package : Rc

Re: [Rcpp-devel] SUGAR: Vector-Scalar operations

2010-12-22 Thread romain
Hmm. It works for me : romain@ /tmp $ Rscript scalar.R Le chargement a nécessité le package : Rcpp Le chargement a nécessité le package : methods Le chargement a nécessité le package : inline [1] 0.118499288 -1.817607621 -0.222048483 -1.237370127 -0.311005542 [6] -1.171129611 -1.762177277

Re: [Rcpp-devel] SUGAR: Vector-Scalar operations

2010-12-22 Thread Cedric Ginestet
Dear Rcpp experts, I've got another problem related to Rcpp Sugar. Basically, I would like to have the same functionality that you get from R's vectors, where binary operations with scalars are automatically interpreted as elementwise operations. See the following code and error message: ###