Re: [Rcpp-devel] [RcppArmadillo] Result of Rcpp Wrap() for Sparse Matrix

2017-06-14 Thread Douglas Bates
On Wed, Jun 14, 2017 at 9:06 AM Serguei Sokol wrote: > Le 14/06/2017 à 15:21, Douglas Bates a écrit : > > > > > > On Wed, Jun 14, 2017 at 3:59 AM Serguei Sokol <mailto:serguei.so...@gmail.com>> wrote: > > > > Le 13/06/2017 à 18:24, Douglas Bates a

Re: [Rcpp-devel] [RcppArmadillo] Result of Rcpp Wrap() for Sparse Matrix

2017-06-14 Thread Douglas Bates
On Wed, Jun 14, 2017 at 3:59 AM Serguei Sokol wrote: > Le 13/06/2017 à 18:24, Douglas Bates a écrit : > > On Tue, Jun 13, 2017 at 10:56 AM Binxiang Ni <mailto:binxian...@gmail.com>> wrote: > > > > Hi, > > > > I am working on fixing sparse ma

Re: [Rcpp-devel] [RcppArmadillo] Result of Rcpp Wrap() for Sparse Matrix

2017-06-13 Thread Douglas Bates
On Tue, Jun 13, 2017 at 10:56 AM Binxiang Ni wrote: > Hi, > > I am working on fixing sparse matrix conversion for RcppArmadillo. Now a > problem comes up to me: what kind of sparse matrix is expected to pass from > Armadillo to R? That is, what should the result of wrap() be? dgCMatrix(if > logic

Re: [Rcpp-devel] symmatu does not give symmetric matrix

2016-07-27 Thread Douglas Bates
First, this is not a good way of constructing a matrix to test the Cholesky decomposition because the result is rank-deficient. It is a 2 by 2 matrix of rank 1. In fact it is the very definition of a rank-1 matrix - a column vector multiplied by its transpose. I am surprised at the result because

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

2014-10-16 Thread Douglas Bates
On Thu, Oct 16, 2014 at 11:35 AM, Kevin Ushey wrote: > I think John's advice is spot on here. The issue is only seen when > `NDEBUG` is not defined. > > I can reproduce the crash (assertion failure) by ensuring I have > > CXXFLAGS=-UNDEBUG > > in my ~/.R/Makevars. Note that: > > 1. An asserti

[Rcpp-devel] Yet another instance of "function 'dataptr' not provided ..."

2014-03-25 Thread Douglas Bates
I must have been away from writing R/Rcpp code for too long. I started off trying to reproduce a calculation that is, literally, a one-liner in Julia. See http://nbviewer.ipython.org/gist/dmbates/9746197 Now admittedly the calculation of the sums of the n choose k possible subsets of size k fro

Re: [Rcpp-devel] RcppEigen: Avoiding accessing elements with coeff(i, j) in sparse matrix

2014-03-25 Thread Douglas Bates
Two other small points. I am assuming that the set of indices in the second argument is sorted. Also, it would be best to declare the function as bool foo(const MSpMat X, const Eigen::Map idx) as in the enclosed On Tue, Mar 25, 2014 at 10:45 AM, Douglas Bates wrote: > The enclosed works

Re: [Rcpp-devel] RcppEigen: Avoiding accessing elements with coeff(i, j) in sparse matrix

2014-03-25 Thread Douglas Bates
The enclosed works on this example. The logic is to check each column in the index set for all the elements of the index set, except the one on the diagonal, being in the set of row indices. I have added some diagnostic output to demonstrate the flow. On Tue, Mar 25, 2014 at 9:48 AM, Douglas

Re: [Rcpp-devel] RcppEigen: Avoiding accessing elements with coeff(i, j) in sparse matrix

2014-03-25 Thread Douglas Bates
On Tue, Mar 25, 2014 at 6:42 AM, Søren Højsgaard wrote: > Dear all, > I have a large sparse adjacency matrix X for an undirected graph. For a > subset 'idx' of the vertices I want to find out if the subgraph defined by > this subset is complete (i.e. has edges between all variables). So in R, > o

Re: [Rcpp-devel] Sparse matrix operations

2014-02-03 Thread Douglas Bates
On Mon, Feb 3, 2014 at 11:48 AM, Dirk Eddelbuettel wrote: > > On 3 February 2014 at 10:23, French, Joshua wrote: > | Soren and Doug, > | > | Thanks for the info about the sparse matrices. I'll give it a go and > seen what > | happens. If it works out, then perhaps I'll be able to provide a nice

Re: [Rcpp-devel] Sparse matrix operations

2014-01-31 Thread Douglas Bates
On Fri, Jan 31, 2014 at 1:14 PM, French, Joshua wrote: > Hello everyone, > > For those of you who have used the sparse matrix capabilities of > Armadillo/RcppArmadillo, how seamless are the operations in moving between > sparse and dense matrices? I know there are some tricks for getting > sparse

Re: [Rcpp-devel] How many copies of my object do I make?

2013-12-10 Thread Douglas Bates
Typo On Tue, Dec 10, 2013 at 11:48 AM, Douglas Bates wrote: > You can avoid one copy operation by declaring X as > > const MSpMat X(as(xx_)); > xx_ should be XX_. ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org htt

Re: [Rcpp-devel] How many copies of my object do I make?

2013-12-10 Thread Douglas Bates
You can avoid one copy operation by declaring X as const MSpMat X(as(xx_)); As it is you are allocating storage for a copy of the sparse matrix which will not be modified and hence does not need to be copied. On Tue, Dec 10, 2013 at 11:33 AM, Dirk Eddelbuettel wrote: > > On 9 December 2013 a

[Rcpp-devel] Question on lme4 book

2013-12-09 Thread Douglas Bates
Yesterday Taylor Russ asked What it the proper citation for the lme4 package and the Bates' book? Also, can lme4 datasets (e.g., Pastes, ScotsSec, InstEval etc.) be used for illustration in publications? Can the authors grant permission or is the permission from the source needed? Many than

Re: [Rcpp-devel] RcppEigen needs 1GB memory to compile

2013-12-02 Thread Douglas Bates
On Mon, Dec 2, 2013 at 2:20 PM, Dirk Eddelbuettel wrote: > > On 2 December 2013 at 13:52, Douglas Bates wrote: > | The important thing is to use the -g0 flag. Even though RcppEigen is a > > Right. > > And for the opencpu server deployment, you may want to edit the -g out

Re: [Rcpp-devel] RcppEigen needs 1GB memory to compile

2013-12-02 Thread Douglas Bates
The important thing is to use the -g0 flag. Even though RcppEigen is a header-only package we include an example R function fastlm. If you leave the symbols in the DLL file you get a massive library size whereas stripping the symbols provides you with a much smaller file size. And because packag

[Rcpp-devel] Header-only version of Rcpp provides a couple of gotcha's in RcppEigen

2013-11-14 Thread Douglas Bates
If I install the latest, header-only, git version of Rcpp (f117a70), which is a great achievement by the way, installation of RcppEigen encounters a few minor problems. One seems to be related to conflicting definitions of trunc in Rmath.h and in fstream In file included from fastLm.cpp:23: In f

[Rcpp-devel] New release of RcppEigen based on Eigen 3.2.0

2013-11-12 Thread Douglas Bates
A new release of RcppEigen based on Eigen 3.2.0 has been uploaded to CRAN. ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

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

2013-11-06 Thread Douglas Bates
Another thing you can do in compiled code that is difficult to do in R is to avoid the allocate/free sequences when calling a code segment thousands of times. R's functional semantics (i.e. the expectation that functions do not modify their arguments) is great - until you really want to overwrite

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

2013-11-06 Thread Douglas Bates
By default Eigen does not use BLAS, which can be good or bad, depending on the situation. I notice that the second largest total time is spent in t.default which may mean that you are using an operation like t(X) %*% X If so, you can save yourself time by using the crossprod or tcrossprod functi

Re: [Rcpp-devel] RcppEigen not compiling under Solaris 10 INTEL

2013-09-30 Thread Douglas Bates
On Mon, Sep 30, 2013 at 4:42 PM, Douglas Bates wrote: > On Mon, Sep 30, 2013 at 4:16 PM, Dirk Eddelbuettel wrote: > >> >> Hi Martyn, >> >> On 30 September 2013 at 21:02, Martyn Plummer wrote: >> | I've already been asked to look into this by Brian. I ca

Re: [Rcpp-devel] RcppEigen not compiling under Solaris 10 INTEL

2013-09-30 Thread Douglas Bates
On Mon, Sep 30, 2013 at 4:16 PM, Dirk Eddelbuettel wrote: > > Hi Martyn, > > On 30 September 2013 at 21:02, Martyn Plummer wrote: > | I've already been asked to look into this by Brian. I can't say I've > rolled up my sleeves very far, but the problem appears to be in Eigen > itself. > > Cool!

Re: [Rcpp-devel] RcppEigen not compiling under Solaris 10 INTEL

2013-09-30 Thread Douglas Bates
Change "either x86 or sparse" to "either x86 or sparc". I write sparse more than I write sparc and my fingers took over. On Mon, Sep 30, 2013 at 4:20 PM, Douglas Bates wrote: > On Mon, Sep 30, 2013 at 3:56 PM, Dirk Eddelbuettel wrote: > >> >> On 30 Septe

Re: [Rcpp-devel] RcppEigen not compiling under Solaris 10 INTEL

2013-09-30 Thread Douglas Bates
On Mon, Sep 30, 2013 at 3:56 PM, Dirk Eddelbuettel wrote: > > On 30 September 2013 at 16:46, Sul, Young L wrote: > | I know that from > http://cran.fhcrc.org/web/checks/check_results_RcppEigen.html > | RcppEigen isn?t compilable until Solaris 10 yet. I?m wondering if anyone > has a > | sense if t

Re: [Rcpp-devel] Symbol not found when including an external library

2013-09-04 Thread Douglas Bates
Do you know of the nloptr and nloptwrap R packages based on NLopt. The nloptr package installs the NLopt library. Unfortunately it does not put the header files in inst/include in the source package so they will be available in the include subdirectory of the installed package. On Wed, Sep 4,

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Douglas Bates
On Tue, Jun 11, 2013 at 10:51 AM, Steve Jaffe wrote: > Is there a way to 'wrap', say, an array of double allocated on the heap in > C/C++ and return it to R without copying, ie as the data inside a REALSXP? > I don't know of any way of doing that. R is very possessive about memory and expects t

Re: [Rcpp-devel] Segfault error during simulation in Rcpp

2013-05-06 Thread Douglas Bates
The segfaults seem to be related to PutRNGstate and I don't see that you have declared an instance of the class that causes the RNGstate to be accessed and restored (I have forgotten the name of the class but it should be fairly easy to find in the examples). When you use random number generators

Re: [Rcpp-devel] Packaging - and even more packaging

2013-02-03 Thread Douglas Bates
On Sun, Feb 3, 2013 at 2:41 PM, Simon Zehnder wrote: > Dear Rcpp-Devels, > > maybe you have an answer for me as packaging is a little new for me: > > I took the NLopt library (http://ab-initio.mit.edu/wiki/index.php/NLopt) > and installed it into a subfolder /nlopt-2.3 in my package-/src folder.

Re: [Rcpp-devel] problem compiling with const in RcppEigen

2013-01-31 Thread Douglas Bates
removing the const from the double* in > the class constructor, etc, but I guess there's the larger question of > whether the RcppEigen 'as' function should be able to form an > Eigen::Map. Thanks for the info regarding the > point of failure. > > Mark A > > On Thu,

Re: [Rcpp-devel] problem compiling with const in RcppEigen

2013-01-31 Thread Douglas Bates
I should check the syntax before sending the message. On Thu, Jan 31, 2013 at 11:30 AM, Douglas Bates wrote: > The as function in RcppEigen can form an > > Eigen::Map > > but doesn't know how to form an > > Eigen::Map > > Generally I find that I confuse myself le

Re: [Rcpp-devel] problem compiling with const in RcppEigen

2013-01-31 Thread Douglas Bates
The as function in RcppEigen can form an Eigen::Map but doesn't know how to form an Eigen::Map Generally I find that I confuse myself less when the const is outside the Eigen::Map. In other words, I use something like typedef Eigen::Map mMat; const mMat M(mat_from_R); This tells me that M i

Re: [Rcpp-devel] Rcpp with C++ and Fortran

2013-01-23 Thread Douglas Bates
Could you clarify a bit, Rodney. When you say you want to "link it with Fortran code" are you using the word "link" in the sense of linking to object code or do you mean that you will copy the Fortran source files into your package's src directory and have them compiled with other source files? T

Re: [Rcpp-devel] RcppEigen: Getting and setting dimnames of sparse matrix

2013-01-19 Thread Douglas Bates
On Sat, Jan 19, 2013 at 10:38 AM, Douglas Bates wrote: > On thinking about this a bit more, the dimnames should be cloned before being assigned, otherwise you end up with two references to the same storage. And once you try to clone you get into the SlotProxy area where you need to know w

Re: [Rcpp-devel] RcppEigen: Getting and setting dimnames of sparse matrix

2013-01-19 Thread Douglas Bates
The Eigen sparse matrix only contains the numeric information, it doesn't contain information like Dimnames that are specific to the R structure. If you want to access the slots or set their values it is easiest to do that with the Rcpp::S4 class object. Of course it helps to use R's str function

Re: [Rcpp-devel] Regarding question on a suitable IDE for C++ project using Rcpp in Window (7) OS

2013-01-10 Thread Douglas Bates
The inability to use Visual Studio for compiling code to use with R is not peculiar to Rcpp. The Windows version of R is compiled with mingw compilers and requires compatible compilers for other code. Remember that R is an Open Source project and Visual Studio isn't. As far as an IDE goes, RStud

Re: [Rcpp-devel] receiving R matrices: question about RcppArmadillo example fastlm

2013-01-10 Thread Douglas Bates
The important question is whether the as copies the contents of the matrix from the SEXP passed by R. Creating an Rcpp::NumericMatrix does not copy the contents and converting the NumericMatrix to an arma::mat with that trailing 'false' also just copies the pointer to the contents, not the content

Re: [Rcpp-devel] Wrapping a C struct in C++ for constructor/destructor

2012-12-15 Thread Douglas Bates
gy >> perhaps. >> >> >> You could also prevent copy ctor and assignment op by making them private >> without an implementation, and always pass them by reference. Then you can >> consider that your c++ object owns the pointer. >> >> >> >> &

[Rcpp-devel] Wrapping a C struct in C++ for constructor/destructor

2012-12-14 Thread Douglas Bates
This is more a C++ question than an Rcpp question although, of course, the application will be through Rcpp. I want to use C functions defined in the CHOLMOD package using Rcpp. The arguments to these functions and the returned values are usually pointers to C structs. There are several such stru

[Rcpp-devel] Wrapping a C struct in a C++ class/struct

2012-12-14 Thread Douglas Bates
This is more of a C++ question than an Rcpp question ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] For a Matrix A, is A(i, j) or A[i, j] preferred as an accessor for an element

2012-12-10 Thread Douglas Bates
On Mon, Dec 10, 2012 at 10:38 AM, Romain Francois wrote: > Le 10/12/12 17:29, Douglas Bates a écrit : > >> or does it matter? >> > > A[i,j] is wrong, not valid C or C++ code. so there is only one choice. > Indeed. Thanks. Somehow I managed to convince myself tha

[Rcpp-devel] For a Matrix A, is A(i, j) or A[i, j] preferred as an accessor for an element

2012-12-10 Thread Douglas Bates
or does it matter? ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] Sparse matrices with RcppArmadillo

2012-12-08 Thread Douglas Bates
On Sat, Dec 8, 2012 at 10:35 AM, c s wrote: > Armadillo sparse matrices are stored in Compressed Sparse Column format: > > > http://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_.28CSC_or_CCS.29 > > This layout is used by a majority of external solvers. > > It would be far more eff

Re: [Rcpp-devel] How to increase the coding efficiency

2012-12-06 Thread Douglas Bates
I don't know as much about Armadillo as I do about Eigen so I will cheat and write using RcppEigen instead of RcppArmadillo. Page 6 of the Eigen tutorial at http://eigen.tuxfamily.org/dox/ discusses decompositions and solving linear systems of equations. One of the simplest ways of solving a weig

Re: [Rcpp-devel] How to increase the coding efficiency

2012-12-05 Thread Douglas Bates
On Tue, Dec 4, 2012 at 9:39 PM, Honglang Wang wrote: > Yes, the main issue for my coding is the allocation of memory. And I have > fixed one of the biggest memory allocation issue: 4000 by 4000 diagonal > matrix. And since I am not familiar with Rcpp and RcppArmadillo, I have no > idea how to reu

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-20 Thread Douglas Bates
On Tue, Nov 20, 2012 at 9:54 AM, Hadley Wickham wrote: > > P.S. I don't think the sugar versions can be made any quicker, because > > they have to allocate intermediate vectors, and do more memory copies. > > I don't think they _have_to - my understanding is that the expression > template approac

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-20 Thread Douglas Bates
On Mon, Nov 19, 2012 at 11:36 AM, Hadley Wickham wrote: > > To be fair with the R language, I would have compare with the use of real > > primitives : > > > > vaccBubu <- function(age, female, ily) { > > gender <- female * 1.25 > > gender[!female] <- 0.75 > > p <- (0.25 + 0.3 * 1 / (1

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-20 Thread Douglas Bates
ing it yet. However, the list administrator has told me not to discuss Julia on this list so I won't :-) On Mon, Nov 19, 2012 at 10:54 AM, Dirk Eddelbuettel wrote: > > On 19 November 2012 at 10:47, Douglas Bates wrote: > | Sigh. Speaking as one of the "Julia guys" I should po

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-19 Thread Douglas Bates
On Mon, Nov 19, 2012 at 9:56 AM, Dirk Eddelbuettel wrote: > > On 19 November 2012 at 09:31, Hadley Wickham wrote: > | Hi all, > | > | Inspired by "Rcpp is smoking fast for agent-based models in data > | frames" (http://www.babelgraph.org/wp/?p=358), I've been doing some > > [ I liked that post, b

Re: [Rcpp-devel] Matrix: column-major storage?

2012-11-07 Thread Douglas Bates
An Rcpp object uses the storage allocated in R hence it has the same column-major ordering of the elements in a matrix. The same is true of matrix objects in RcppArmadillo. Basically anything that uses Lapack and BLAS or calling sequences compatible with Lapack or BLAS uses column-major ordering.

Re: [Rcpp-devel] Vectorized version of rbinom function via Rcpp

2012-10-25 Thread Douglas Bates
On Thu, Oct 25, 2012 at 9:29 AM, Dirk Eddelbuettel wrote: > > Hi Carsten, > > On 25 October 2012 at 16:05, carsten Gerken wrote: > | Hi All, > | > | I am trying to outsource the simulation of binomially distributed random > | variables to C++ via Rcpp (e.g. to replicate the R command > rbinom(10,

Re: [Rcpp-devel] Slices of 3d arrays as matrices

2012-10-24 Thread Douglas Bates
want to modify in there. Environments behave differently from other R objects in that there is only ever one copy of an environment so changes in the objects in an environment made in one place are reflected in all other views of the environment. > From: dmba...@gmail.com [dmba...@gm

Re: [Rcpp-devel] R/Rcpp/RcppEigen Optimization WAS: NumericVector Double mismatch when indexing an array

2012-10-24 Thread Douglas Bates
On Tue, Oct 23, 2012 at 6:01 PM, Darren Cook wrote: >> What gives? What I found that does speed up the code dramatically >> is the -march switch. I guess that can't be repo-ed because it is >> CPU dependent, right? Here's the important settings that I used to >> compile R from source: >> >> CC=

Re: [Rcpp-devel] Slices of 3d arrays as matrices

2012-10-24 Thread Douglas Bates
on RcppEigen. It would be worthwhile reading that vignette if you want to use RcppEigen, and also read at least the tutorial in the Eigen3 documentation. I would start with something like the enclosed but that code doesn't compile and gives the usual page after page of reports when compiling Eigen-base

Re: [Rcpp-devel] Slices of 3d arrays as matrices

2012-10-23 Thread Douglas Bates
On Tue, Oct 23, 2012 at 12:56 PM, Giovanni Petris wrote: > Hello, > > I have a 3d array and I want to compute the eigendecomposition of each slice > [,, k]. I am trying to make Rcpp see the relevant slice of the 3d array as a > matrix. My experiments, along the lines illustrated below, have so f

Re: [Rcpp-devel] 'Nested' Rcpp functions using inline

2012-10-10 Thread Douglas Bates
Remember that the inline package is convenient for interactive exploration during code development but usually the ultimate goal when working with Rcpp is to produce a package including both R and C++ code. When you start doing complicated things in the C++ code it is probably time to look at crea

Re: [Rcpp-devel] Correlation in ArmadilloRcpp with missing values (nan)

2012-10-09 Thread Douglas Bates
On Tue, Oct 9, 2012 at 1:06 PM, mateusz.ka...@gmail.com wrote: > Maybe I am not good in coding, but even though I managed to make uvec with > ones and zeros, I cannot use it to select rows in given column, compiler > complains > error: no matching function for call to > ‘arma::Mat::submat(arma::u

Re: [Rcpp-devel] Correlation in ArmadilloRcpp with missing values (nan)

2012-10-09 Thread Douglas Bates
Just for the record, earlier Dirk mentioned functions R_IsNA, R_IsNaN and R_IsFinite. The last one should be R_finite. ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-de

Re: [Rcpp-devel] Correlation in ArmadilloRcpp with missing values (nan)

2012-10-09 Thread Douglas Bates
ess >> then one minute. But I skipped columns with missing cells, which now I want >> to include. >> >> Thanks, >> Mateusz >> >> >> On 9 October 2012 17:37, Dirk Eddelbuettel wrote: >>> >>> >>> On 9 October 2012 at 10:08

Re: [Rcpp-devel] Correlation in ArmadilloRcpp with missing values (nan)

2012-10-09 Thread Douglas Bates
You may find it easier to use the Rcpp class NumericMatrix than to use RcppArmadillo. Detection of NA's is built in to R and Rcpp classes but not RcppArmadillo. For each pair of columns, run a loop that checks for NA's at each position in each column, skips the position if NA's are detected and ot

Re: [Rcpp-devel] How to use R function mvrnorm in c++?

2012-10-08 Thread Douglas Bates
On Mon, Oct 8, 2012 at 4:23 PM, Victor wrote: > Dear all, > > I want to use R function mvrnorm (package MASS) in my c++ scripts. Below is > the R code: > > library(MASS) > > x<-matrix(c(1.5,0,0,0,1.5,0,0,0,1.5),3,3) > > mvrnorm(1,c(15,33,26),x) > > > I will appreciate you very much if

Re: [Rcpp-devel] Missing PROTECT()s in forward_exception_to_r()?

2012-10-08 Thread Douglas Bates
On Mon, Oct 8, 2012 at 6:42 AM, Dirk Eddelbuettel wrote: > > Hi Ben, > > On 8 October 2012 at 10:24, North, Ben wrote: > | Hi, > | > | I've been using Rcpp for a while now, and finding it very useful --- > | thanks! > | > | Recently, though, I came across strange behaviour when running under > | g

Re: [Rcpp-devel] NumericVector Double mismatch when indexing an array

2012-09-25 Thread Douglas Bates
On Tue, Sep 25, 2012 at 1:53 PM, Rodney Sparapani wrote: > On 09/25/2012 01:37 PM, Goldfeld, Keith wrote: > >>> code<- 'Rcpp::RNGScope scope; >> >> >> +Rcpp::NumericVector rn(5); >> >> +for (int i=0; i< 5; i++) { >> >> +rn(i) = rnor

Re: [Rcpp-devel] Getting and setting array dimensions - simpler ways?

2012-09-10 Thread Douglas Bates
On Mon, Sep 10, 2012 at 8:55 AM, Søren Højsgaard wrote: > Dear list, > > I want to do some operations on an array, here exemplified by taking log (the > operations I have in mind are made using RcppArmadillo): > >> pp <- array(c(.1, .4, .4, .1), dim=c(2,2),dimnames=list(A=c("a1","a2"), >> B=c("

Re: [Rcpp-devel] Dirk's benchmarking of code for creation of random binary matrices

2012-09-04 Thread Douglas Bates
Slightly different results if I clean up the eigenFloor version and use unif_rand() instead of runif. The sugar version is still faster, however. R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_

[Rcpp-devel] Dirk's benchmarking of code for creation of random binary matrices

2012-09-04 Thread Douglas Bates
Dirk Eddelbuettel recently blogged on "Faster creation of binomial matrices" (http://dirk.eddelbuettel.com/blog/code/snippets/) comparing various approaches in R and using C++ callable from R with the Rcpp package. I used cut-and-paste to create a script from the code in his posting but omitting t

Re: [Rcpp-devel] Advice on installing CHOLMOD/Suitesparse

2012-08-31 Thread Douglas Bates
On Fri, Aug 31, 2012 at 11:35 AM, Rodney Sparapani wrote: > On 08/31/2012 11:20 AM, Douglas Bates wrote: >> >> We seem to be talking at crossed purposes. >> >> What I meant to say is that for some mysterious reason the standard R >> configuration defines &g

Re: [Rcpp-devel] Advice on installing CHOLMOD/Suitesparse

2012-08-31 Thread Douglas Bates
sparse and Eigen just for the purposes of using RcppEigen. If so, you don't need to have them. Between the Matrix package and Rcpp and RcppEigen all the necessary code is provided in R packages. On Fri, Aug 31, 2012 at 8:51 AM, Rodney Sparapani wrote: > On 08/30/2012 05:53 PM, D

Re: [Rcpp-devel] Advice on installing CHOLMOD/Suitesparse

2012-08-30 Thread Douglas Bates
On Thu, Aug 30, 2012 at 4:29 PM, Rodney Sparapani wrote: > On 08/30/2012 04:14 PM, Douglas Bates wrote: >> >> It is quite possible that you would have gotten a buggy version if you >> checked out a copy of the SVN archive at some random time. Making >> such a change i

Re: [Rcpp-devel] Advice on installing CHOLMOD/Suitesparse

2012-08-30 Thread Douglas Bates
Somehow you have obtained a buggy version of RcppEigen_0.3.1.tar.gz I just downloaded that file from a CRAN mirror and this version has the file RcppEigen/inst/include/Eigen/CholmodSupport starting with #ifndef EIGEN_CHOLMODSUPPORT_MODULE_H #define EIGEN_CHOLMODSUPPORT_MODULE_H #include "SparseC

Re: [Rcpp-devel] Advice on installing CHOLMOD/Suitesparse

2012-08-30 Thread Douglas Bates
On Thu, Aug 30, 2012 at 12:41 PM, Rodney Sparapani wrote: > On 08/29/2012 04:42 PM, Douglas Bates wrote: >> >> Perhaps you have an out-of-date version of the RcppEigen package (or >> maybe the Mac version hasn't been built or ...). In any case >>

Re: [Rcpp-devel] Advice on installing CHOLMOD/Suitesparse

2012-08-29 Thread Douglas Bates
iler error in yet another very old compiler. It seems to have compiled and passed its checks on r-release-macosx-ix86 and I think that is now using the clang compiler. On Wed, Aug 29, 2012 at 4:43 PM, Douglas Bates wrote: > On Wed, Aug 29, 2012 at 4:42 PM, Douglas Bates wrote: >> On Wed

Re: [Rcpp-devel] Advice on installing CHOLMOD/Suitesparse

2012-08-29 Thread Douglas Bates
On Wed, Aug 29, 2012 at 4:42 PM, Douglas Bates wrote: > On Wed, Aug 29, 2012 at 4:32 PM, Rodney Sparapani wrote: >> Hi Gang: >> >> I have been using CHOLMOD/Suitesparse, but I'm having an issue >> coaxing RcppEigen to see it. I have Matrix, inline, Rcpp and &

Re: [Rcpp-devel] Advice on installing CHOLMOD/Suitesparse

2012-08-29 Thread Douglas Bates
On Wed, Aug 29, 2012 at 4:32 PM, Rodney Sparapani wrote: > Hi Gang: > > I have been using CHOLMOD/Suitesparse, but I'm having an issue > coaxing RcppEigen to see it. I have Matrix, inline, Rcpp and > RcppEigen installed as well as Suitesparse. But, when I run > this simple program (that works wi

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

2012-08-27 Thread Douglas Bates
On Mon, Aug 27, 2012 at 3:17 PM, Peng Yu wrote: > Hi Dirk, > >> inlines uses .Call, so there is a slight logical problem here... And yes, > > What is the logical problem? Dirk is trying to point out that the two calls are using the same mechanism. All that the inline package does is wrap the pr

Re: [Rcpp-devel] Convertion from SEXP to std::vector

2012-08-22 Thread Douglas Bates
On Wed, Aug 22, 2012 at 9:55 AM, Peng Yu wrote: > Hi, > > Rcpp::IntegerVector can not be converted to std::vector. Is > there a class that can help convert SEXP to std::vector? > > The current walkaround can be something like the following. I'm > wondering if there is a better solution? > > Rcpp::

Re: [Rcpp-devel] How to manage testing code for Rcpp based project?

2012-08-22 Thread Douglas Bates
On Wed, Aug 22, 2012 at 12:16 AM, Davor Cubranic wrote: > On 12-08-21 09:54 PM, Darren Cook wrote: RUnit works, but the setup is not the easiest. If someone has ideas for better solutions, by all means implement those. Unit testing has helped us many times, and I consider

Re: [Rcpp-devel] RNGScope

2012-08-14 Thread Douglas Bates
I think you want to move the RNGScope declaration before the calls to rcauchy and runif. On Tue, Aug 14, 2012 at 9:17 AM, Rodney Sparapani wrote: > This is my first post so please be gentle ;o) I have been through > all of the docs that I can find (but I haven't looked at the source > code direc

Re: [Rcpp-devel] clarification of interaction between RInside and RcppEigen

2012-08-07 Thread Douglas Bates
Probably the best place to start with RcppEigen is the vignette that Dirk and I wrote for the RcppEigen package. I can email you a copy of the PDF file off-list if you wish. With RcppEigen you can skip the creation of an Rcpp::NumericMatrix object if you wish and go directly to a mapped Eigen Mat

Re: [Rcpp-devel] How to manage testing code for Rcpp based project?

2012-08-04 Thread Douglas Bates
On Sat, Aug 4, 2012 at 11:48 AM, Peng Yu wrote: >> Seriously: please think through what you are suggesting here. We are talking >> about __compiled language__ and outside of a time machine I see very few >> tools that would permit you to __test before installation__. > > You clearly exaggerated m

Re: [Rcpp-devel] How to manage testing code for Rcpp based project?

2012-08-04 Thread Douglas Bates
On Sat, Aug 4, 2012 at 11:22 AM, Peng Yu wrote: > Hi, > > I have trouble in finding a good strategy for organizing test cases to > have complete coverage for Rcpp based code. > > The example in RcppArmadillo_0.3.2.4/inst/unitTests has some problem > in the sense that, each file is too large --- if

Re: [Rcpp-devel] bounds checking disabled for RcppEigen?

2012-08-01 Thread Douglas Bates
I don't really think that bounds checking is slowing down this calculation. You can make the whole thing run faster by the simple expedient of reordering the loops. For me, this version STLvectortest<-' const NumericMatrix X = Rcpp::as(mat); int p = X.nrow(); std::vector V(p*p); // Copy data in

Re: [Rcpp-devel] bounds checking disabled for RcppEigen?

2012-08-01 Thread Douglas Bates
On Wed, Aug 1, 2012 at 12:46 PM, Andrew Slaughter wrote: > First of all, great job with Rcpp - it's an awesome tool, and finally gave > me a reason to go back to my C++ books and get beyond "Hello World"! > > I did have a question about RcppEigen, though: specifically, when I use > RcppEigen throu

Re: [Rcpp-devel] dyn.load error - symbol not found - expected in: flat namespace

2012-07-18 Thread Douglas Bates
One way forward is to use a program like c++filt to demangle the name that is not found. It is re2::RE2::Arg::parse_float(char const*, int, void*) On Wed, Jul 18, 2012 at 11:18 AM, Lescai, Francesco wrote: > I'm still having this problem. > I progressively increased the complexity of my code, b

Re: [Rcpp-devel] Very Large Matrices in RcppArmadillo

2012-07-17 Thread Douglas Bates
es. > > Joshua > -- > Joshua French, Ph.D. > Assistant Professor > Department of Mathematical and Statistical Sciences > University of Colorado Denver > joshua.fre...@ucdenver.edu > http://math.ucdenver.edu/~jfrench/ > Ph: 303-556-6265 Fax: 303-556-8550 > > > >

Re: [Rcpp-devel] Very Large Matrices in RcppArmillao

2012-07-17 Thread Douglas Bates
On Tue, Jul 17, 2012 at 8:14 AM, Dirk Eddelbuettel wrote: > > On 16 July 2012 at 23:30, French, Joshua wrote: > | I am doing some linear algebra on large matrices in R and receiving the > | following error: "allocMatrix: too many elements specified". From what I > | understand, the error is caus

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

2012-06-29 Thread Douglas Bates
On Fri, Jun 29, 2012 at 6:18 AM, Silkworth,David J. wrote: > With respect to replies: >  > a) fit a decent, modern, documented C++ implementation of what is needed > > Yes, this was the question.  Can anyone help?  I am failing right here. > >> and of course if a) fails, one can always 'rip out' w

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

2012-06-28 Thread Douglas Bates
On Thu, Jun 28, 2012 at 8:08 AM, Silkworth,David J. wrote: > Folks, I am bravely helping Gianluca Bonitta (a.k.a. bbo...@tin.it) develop > an Rcpp solution for his thesis, he already has a functioning R prototype. > He has been using ns() from the splines library (thank-you Doug Bates!), and > we

Re: [Rcpp-devel] check validity of object created from Rcpp module

2012-06-27 Thread Douglas Bates
On Tue, Jun 26, 2012 at 7:04 PM, Dirk Eddelbuettel wrote: > > On 26 June 2012 at 17:21, Jiqiang Guo wrote: > | Dear List, > | > | I am wondering if there is a way to check whether an object created from > Rcpp's > | module is valid or not especially for objects loaded in another session. > | > |

Re: [Rcpp-devel] Persistent C++ objects within R/Rcpp?

2012-06-25 Thread Douglas Bates
On Mon, Jun 25, 2012 at 3:38 PM, Andy Garcia wrote: > First, thank you to the Rcpp team for their work on Rcpp. It's an incredible > resource to get C++ code executing from R. > > I've worked through setting up the correct development environment (Ian > Fellow's post on Eclipse + Rcpp was great wi

Re: [Rcpp-devel] Using sparse matrices from the Matrix package in Rcpp

2012-06-25 Thread Douglas Bates
On Sun, Jun 24, 2012 at 1:19 PM, Dirk Eddelbuettel wrote: > > On 24 June 2012 at 19:56, Glenn Lawyer wrote: > | I would suggest using the eigen library, Rccp has an interface to this. > | Alternately, you could link to the boost graph library. > > Spot on. > > It was in fact the availability of (m

Re: [Rcpp-devel] Call R function

2012-06-21 Thread Douglas Bates
On Wed, Jun 20, 2012 at 4:30 PM, bbo...@tin.it wrote: > > i must use it to evaluate  matropolis ratio (green ratio) in the following > code in R :  i have  start just  now to study c and c++   (like you can see > by my stupids questions (for you surely))  if  you have some suggestion im > very hap

Re: [Rcpp-devel] Call R function (bbo...@tin.it)

2012-06-20 Thread Douglas Bates
On Wed, Jun 20, 2012 at 11:22 AM, Silkworth,David J. wrote: > I am not going to ask why to do this, but here is a way how. > > I added your R function into the mypackage skeleton from RcppPackage > > R_user_F<-function (par) { > y<-par[1] > x<-par[2] > return(dnorm(x)*dnorm(y)) > } > > I prefer to

Re: [Rcpp-devel] Call R function

2012-06-20 Thread Douglas Bates
I enclose a rewrite of your function R version 2.15.0 (2012-03-30) Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain con

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 when compile appear t

Re: [Rcpp-devel] Differences between RcppEigen and RcppArmadillo

2012-06-18 Thread Douglas Bates
On Sun, Jun 17, 2012 at 11:09 PM, c s wrote: > On Sun, Jun 17, 2012 at 4:21 AM, Douglas Bates wrote: >> These comments may provoke a heated response from Conrad but, >> if so, I don't plan to respond further.  Eigen and Armadillo are different >> approaches, each wit

Re: [Rcpp-devel] Differences between RcppEigen and RcppArmadillo

2012-06-16 Thread Douglas Bates
On Thu, Jun 14, 2012 at 2:36 PM, Dirk Eddelbuettel wrote: > > On 15 June 2012 at 02:56, c s wrote: > | Simply installing ATLAS (which provides speed-ups for several Lapack > | functions) on Debian/Ubuntu systems can already make a big difference. > |  (Debian & Ubuntu use a trick to redirect Lapac

Re: [Rcpp-devel] Differences between RcppEigen and RcppArmadillo

2012-06-14 Thread Douglas Bates
gt; On Wed, Jun 13, 2012 at 4:07 PM, Douglas Bates wrote: >> >> On Wed, Jun 13, 2012 at 5:16 PM, Dirk Eddelbuettel wrote: >> > >> > On 13 June 2012 at 15:05, Julian Smith wrote: >> > | I agree that RcppEigen is a little bit faster, but ease of use is >&g

Re: [Rcpp-devel] Differences between RcppEigen and RcppArmadillo

2012-06-13 Thread Douglas Bates
On Wed, Jun 13, 2012 at 5:16 PM, Dirk Eddelbuettel wrote: > > On 13 June 2012 at 15:05, Julian Smith wrote: > | I agree that RcppEigen is a little bit faster, but ease of use is important > to > | me, so I feel like RcppArmadillo might win out in my application. > > Yup, that my personal view too

[Rcpp-devel] Memory error when using Dimension

2012-06-05 Thread Douglas Bates
Some time ago I mentioned memory errors that seemed to be related the the Rcpp::Dimension class but I couldn't pin them down. I have a more detailed, although not necessarily reproducible, example now. In the merPredD::condVar method defined in the lme4/src/predModule.cpp source file there is the

Re: [Rcpp-devel] Including a compiled function with inline

2012-06-04 Thread Douglas Bates
On Mon, Jun 4, 2012 at 4:19 AM, Marie Auger-Methe wrote: > Hi list, > I am writing a Rcpp function (referred as f2). To be able to debug it, I am > currently using inline to write f2. f2 uses a function that I've wrote and > is now part of a package that I have made (referred as f1). f1 is an Rcp

  1   2   3   4   5   >