From enrico.bibbona at unito.it  Tue Nov  3 12:16:47 2015
From: enrico.bibbona at unito.it (Enrico Bibbona)
Date: Tue, 3 Nov 2015 12:16:47 +0100
Subject: [Rd] Fwd: Rcpp sugar dpois
In-Reply-To: <CAFvnaTYbPv8heJK9geL3gTTG7bUqqWv5yN2yjdjjkXzxDz8hkg@mail.gmail.com>
References: <CAFvnaTYbPv8heJK9geL3gTTG7bUqqWv5yN2yjdjjkXzxDz8hkg@mail.gmail.com>
Message-ID: <CAFvnaTaqGzewyfvuMowHHELWDi6p4-0ueYBA5Yd83-6OuskBzQ@mail.gmail.com>

Hi. Here is a piece of cpp code.
It works, but I do not understand the rational for the use of
"R::dpois" to call the function dpois since in the examples I have always
found directly "dpois" or "Rcpp::dpois" that both do not work in my code.
Could anyone be so patient to explain me why should it be like that?
Thaks a lot, Enrico

#include <Rcpp.h>
using namespace Rcpp;
NumericVector pcUtildedatoU(NumericVector z, double j, double par)

{
    int l_z=z.size();
    NumericVector out(l_z);
    for (int w=0; w<= (l_z-1); w++)
    {
        double outcand=0;
        double d=z[w];
        if (d >= j)
            outcand=1;
        else if (d>= -j)
        {
            for(int i=-j; i<=d; i+=2)
                outcand+= R::dpois((i+j)/2, par,false)* R::dpois((j-i)/2,
par,false);
            outcand=outcand/R::dpois(j, 2*par,false);
        }
        out[w]=outcand;
    }
    return out;
}

-- 
Enrico Bibbona
Dipartimento di Matematica
Universit? di Torino
https://sites.google.com/site/enricobibbona/



-- 
Enrico Bibbona
Dipartimento di Matematica
Universit? di Torino
https://sites.google.com/site/enricobibbona/

	[[alternative HTML version deleted]]



[Rd] Fwd: Rcpp sugar dpois
Enrico Bibbona