Re: [Rcpp-devel] Please help in testing what will be Rcpp 1.0.5

2020-06-16 Thread William Dunlap
Your Makevar.site is incorrect. Replace CXX11 = $CXX with CXX11 = $(CXX) $CXX only expands the macro 'C', not 'CXX'. Since C is not defined $CXX expands to XX. Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Jun 16, 2020 at 12:39 PM Thell Fowler wrote: > Windows 10 Pro 2004190

Re: [Rcpp-devel] Debugging intermittant vignette re-building failure

2019-01-08 Thread William Dunlap
--- re-building ‘lolog-ergm.Rmd’ using rmarkdown Quitting from lines 69-75 (lolog-ergm.Rmd) Error: processing vignette 'lolog-ergm.Rmd' failed with diagnostics: unimplemented type (28) in 'duplicate' I don't believe there is a type (*SXP) 28 in R. This could be due to memory misuse. Have you tri

Re: [Rcpp-devel] Error creating package with RcppArmadillo

2018-10-13 Thread William Dunlap
But do replace pkgKitten's boilerplate before submitting the package to CRAN, lest CRAN people decide to insist on meaningful content. ./RApiDatetime/man/RApiDatetime-package.Rd: This section should provide a more detailed overview of how to use the ./SimplifyStats/man/SimplifyStats-package.Rd:

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

2016-12-13 Thread William Dunlap
Could the c++ slowdown be due to the fact that Rinternals.h defines ISNAN differently for C and C++? For C it uses the compiler's isnan macro, for C++ it calls the function R_isnancpp. Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Dec 13, 2016 at 5:04 AM, Christian Gunning wrote: > > |

Re: [Rcpp-devel] Logic error causes R memory to be corrupt

2016-10-06 Thread William Dunlap
Replacing the PROTECT and UNPROTECT_PTR with R_PreserveObject and R_ReleaseObject will probably take care of the unbalanced-protection-stack warnings, but I don't know if there would be any bad interactions with anything else in Rcpp. Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, Oct 6, 20

Re: [Rcpp-devel] Rcpp example that crashes on 64 bit Windows

2016-08-11 Thread William Dunlap
Have you tried running your code on the Mac after setting gctorture(TRUE)? By the way, valgrind showed the opposite of a memory leak - the code was using memory that it had declared free. A leak is when the code does not free memory that it can no longer use. Bill Dunlap TIBCO Software wdunlap t

Re: [Rcpp-devel] Rcpp example that crashes on 64 bit Windows

2016-08-11 Thread William Dunlap
Using 'valgrind', along with gctorture(TRUE) can help track down these bugs. E.g. % R --debugger valgrind ==8445== Memcheck, a memory error detector ==8445== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. ==8445== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info =

Re: [Rcpp-devel] NA_REAL in RcppParallel

2016-06-02 Thread William Dunlap
> if (std::isnan(input[i])) { > output[i] = NA_REAL; // this is the desired output (instead of NAN) In this case I think you could replace the second line with output[i] = input[i]; to emulate the usual R mapping of NA to NA and NaN to NaN. (I have seen C compilers that messed up my pro

Re: [Rcpp-devel] List of Lists to List of Vectors

2015-05-02 Thread William Dunlap
Here is one way to do it in R. Much of the code is checking that the format of 'x' is what you describe and you may omit it if you know that does not need checking. The call to 'unlist' in the call to lapply is responsible for setting the classes of the outputs. Since translation from R to Rcpp i

Re: [Rcpp-devel] rpois returns double?

2015-04-25 Thread William Dunlap
Note that the R function rpois() always returns an integer vector and thus commonly runs into problems when lambda is near or above 2^31 (the smallest positive integral double that cannot represented as a 32-bit signed integer). > set.seed(1) > rpois(10, 2^31) [1] 2147454617 NA NA

Re: [Rcpp-devel] RcppArmadillo and Rdefines

2015-02-25 Thread William Dunlap
Why do you include "Rdefines.h" in your Rcpp code? It contains errors (e.g., it leaves the initial Rf_ off of the length function). Also, in my opinion, it is obsolete, especially for Rcpp code, since it is for writing code that works in R and S (including S+) and Rcpp will never work in S+. Bil

Re: [Rcpp-devel] RcppArmadillo and Rdefines

2015-02-24 Thread William Dunlap
Do you really need the macros like GET_LENGTH that are defined in #include ? It looks like they are meant to ease porting of C code written for S or S+, but very little code these days is written for S or S+ and certainly not Rcpp code. Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Fe

Re: [Rcpp-devel] Rcpp: Modification of input argument: Undefined behaviour

2014-11-26 Thread William Dunlap
> The `mode()` function was pretty useless for determining a matrix object's type Use the storage.mode() function. Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Nov 26, 2014 at 9:06 AM, David Shih wrote: > Hi Yixuan, > > > You're right! > > > Whether the input matrix can be modified

Re: [Rcpp-devel] tracking volatile bug

2014-11-23 Thread William Dunlap
> In quickref, all examples pass just numbers without any prior conversion > to NumericVector or IntegerVector. Strings are exception to this? Strings are different than numbers in that they don't occupy a fixed amount of space, so some memory management is needed for them. Bill Dunlap TIBCO Sof

Re: [Rcpp-devel] tracking volatile bug

2014-11-18 Thread William Dunlap
> I will try "gctorture(TRUE)" suggested by Martin. Try running it under valgrind as well. E.g., % R --debugger=valgrind ==15338== Memcheck, a memory error detector ==15338== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. ==15338== Using Valgrind-3.7.0 and LibVEX; rerun w

Re: [Rcpp-devel] dyn.load error with particular functor

2014-10-22 Thread William Dunlap
Why don't you make track non-static instead? Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Oct 22, 2014 at 12:03 PM, nate russell wrote: > Just for the sake of completeness, I noticed that the value of > trackIdx::tracker was persisting (and therefore continuing to be > incremented) betwe

Re: [Rcpp-devel] (Very) rare segfault

2014-08-20 Thread William Dunlap
The point of gctorture(TRUE), preferably used with an address-validity checker like valgrind, is that you are alerted the first time you use an address that you did not allocate for your use. With gctorture(FALSE) you are alerted after the n'th bad usage, where n depends on when the garbage collec

Re: [Rcpp-devel] "Error during wrapup"

2014-05-29 Thread William Dunlap
You can get more information about intermittent problems like this by running R under valgrind and using gctorture(TRUE). It will run very slowly, but valgrind will flag the first time you use memory that is not currently allocated by new or malloc. Without valgrind you only see a problem if the

Re: [Rcpp-devel] How much speedup for matrix operations?

2013-11-10 Thread William Dunlap
E <- (exp(A) * (1 - 1 / A) + 1 / A) / (exp(A) - 1) If A is a matrix by then, isn't exp a very slow (and imprecise: http://blogs.mathworks.com/cleve/2012/07/23/a-balancing-act-for-the-matrix-exponential/) operation, isn't it? You do it twice on the same matrix. exp(A) is the element-by-e

Re: [Rcpp-devel] Getting the exact arithmetic as in R when Rcpp is used?

2013-07-08 Thread William Dunlap
> Is there a way to get the exact arithmetic as in R? Make your sum quad precision ('long double' in g++). % cat s.cpp #include int main(int argc, char *argv[]) { double dSum(0.0); long double ldSum(0.0); for(int i=0 ; i < 10 ; i++) { dSum += 0.1; ldSum += 0.1; }

Re: [Rcpp-devel] Setting the R random seed from Rcpp

2013-06-07 Thread William Dunlap
This would be easier if base::set.seed() accepted a value of .Random.seed instead of just a scalar integer or, new to R-3.0.0, NULL. If set.seed() returned the previous value of .Random.seed (NULL if there was no previous value) things might be even easier. People should not have to know where .