Re: [Rcpp-devel] 4-dimensional array

2018-04-18 Thread Jeffrey Pollock
The Eigen tensor module (easily available via RcppEigen as far as I can tell) might be worth a look: http://eigen.tuxfamily.org/index.php?title=Tensor_support On Wed, Apr 18, 2018 at 3:13 AM, Dirk Eddelbuettel wrote: > > On 18 April 2018 at 01:56, Avraham Adler wrote: > | May not be possible. Se

Re: [Rcpp-devel] function modifying it self its argument

2015-02-26 Thread Jeffrey Pollock
Perhaps use the clone() function? library(Rcpp) cppFunction(" NumericVector par_CMAtR(NumericVector vec_CMA) { NumericVector out = clone(vec_CMA); out[5] = exp(out[5]); return out; } ") vec_C <- rep(1, 6) par_CMAtR(vec_C) print(vec_C) On Thu, Feb 26, 2015 at 3:16 PM, Pierre GLOAGUEN

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

2012-10-10 Thread Jeffrey Pollock
I think you need to use the `includes` argument of cxxfunction to include a pure c++ function ie; library(inline) library(Rcpp) inc <-' int fun1(double x, double y) { return (exp(x) - y) > 0 ? 1 : 0; } ' body <-' NumericVector u = as(u_r); do

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

2012-09-28 Thread Jeffrey Pollock
Would it be useful to consider using the Function class in Rcpp? You can pass R functions in as arguments like so; library(inline) library(Rcpp) example <- cxxfunction(signature(f_ = "Function"), body = ' Rcpp::Function f(f_); Rcpp::NumericVector out = f(10, 1);

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

2012-09-25 Thread Jeffrey Pollock
rom:* Jonathan Olmsted [mailto:jpolms...@gmail.com] > *Sent:* Tuesday, September 25, 2012 4:29 PM > *To:* Jeffrey Pollock > > *Cc:* Goldfeld, Keith; rcpp-devel@lists.r-forge.r-project.org > *Subject:* Re: [Rcpp-devel] NumericVector Double mismatch when indexing > an array**

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

2012-09-25 Thread Jeffrey Pollock
I was interested to see if there was any real speed difference between the different methods suggested, and it looks like... there isn't... library(inline) library(Rcpp) library(rbenchmark) fun1 <- cxxfunction(body = ' RNGScope scope; NumericVector rn(5);

Re: [Rcpp-devel] pnorm/qnorm?

2012-09-10 Thread Jeffrey Pollock
Try; require(Rcpp) require(inline) check2 <- cxxfunction(signature(arg1 = "numeric", arg2 = "numeric"), ' NumericVector q(arg1); double mean = as(arg2); double sd = 1.0; return wrap(qnorm(q, mean, sd)); ', plugin = "

Re: [Rcpp-devel] Generalized Linear Model funcitonality inside Inline

2012-01-13 Thread Jeffrey Pollock
One way of speeding that up would be to use `glm.fit` instead of `glm`. It just means you'll have to calculate a few extra variables outside the loop (which `glm` will be calculating every time you call it). On Fri, Jan 13, 2012 at 2:53 PM, Jason LaCombe < jlaco...@naturesourcegenetics.com> wrote:

[Rcpp-devel] Fwd: Rcpp too good to be true?

2011-12-13 Thread Jeffrey Pollock
18.59 0.02 ------ Forwarded message -- From: Jeffrey Pollock Date: Tue, Dec 13, 2011 at 11:48 PM Subject: Rcpp too good to be true? To: r-de...@r-project.org Hello all, I've been working on a package to do various things related to the Conway-Maxwell-Poisson distribution and wan

Re: [Rcpp-devel] Easy way to subset a matrix

2011-09-21 Thread Jeffrey Pollock
I had a bash at this as I'm currently learning some C++ / Rcpp. I made a function where you pass in the row start index and row end index, and the desired matrix column (which is what I assumed you would want). Here is the code I came up with including some benchmarks I ran, interestingly, using a

Re: [Rcpp-devel] arma::mat and Rcpp::NumericMatrix

2011-09-17 Thread Jeffrey Pollock
Hey Christian, Thanks very much for the great reply! Will do some more testing and post my results hopefully sometime next week. Jeff On Fri, Sep 16, 2011 at 11:18 PM, Christian Gunning wrote: > Jeff, > > A few random comments in addition to Dirk's sound advice: > > 1. I recommend using bigge

Re: [Rcpp-devel] arma::mat and Rcpp::NumericMatrix

2011-09-16 Thread Jeffrey Pollock
ettel wrote: > > Hi Jeffrey, > > And welcome! Thanks for a detailed post with examples and benchmarks! > > On 16 September 2011 at 14:48, Jeffrey Pollock wrote: > | Hello all, > | > | I've recently started looking into the speed gains from using Rcpp and > have >

[Rcpp-devel] arma::mat and Rcpp::NumericMatrix

2011-09-16 Thread Jeffrey Pollock
Hello all, I've recently started looking into the speed gains from using Rcpp and have began looking into the arma library too. Ive written a small loop to fill in a matrix and done so using the arma::mat class and the Rcpp::NumericMatrix class. In this case, the Rcpp::NumericMatrix class was slig

[Rcpp-devel] installing Rcpp on windows

2011-08-24 Thread Jeffrey Pollock
Hello, I'm trying to get Rcpp to work on my machine running Windows 7 64 bit but I'm not having much luck! I've reinstalled R in: C:\opt\R-2.13.1 and have: C:\Rtools\MinGW64 my path variables are set as: C:\Rtools\bin;C:\Rtools\perl\bin;C:\Rtools\MinGW64\bin;C:\opt\R-2.13.1\bin\x64;C:\Program Fil