Hi

when I call the function below in R, i get the error: Object 'pairlist'
can't be converted to 'double'.

#include <R.h>
#include <Rdefines.h>
#include <Rmath.h>

SEXP CSimPoisson(SEXP lambda, SEXP tgrid, SEXP T2M, SEXP Ni, SEXP NT)
{
        double sign, EVar;
        double *xlambda, *xtgrid, *xT2M, *xNi, *xNT, *xtau;
        SEXP tau;
        int ltgrid =0;
        int i = 0;
        int j = 0;
        sign = 0;
        EVar = 0;
        
        ltgrid  = LENGTH(tgrid);
        PROTECT(lambda = AS_NUMERIC(lambda));
        PROTECT(tgrid = AS_NUMERIC(tgrid));
        PROTECT(T2M = AS_NUMERIC(T2M));
        PROTECT(Ni = AS_NUMERIC(Ni));
        PROTECT(NT = AS_NUMERIC(NT));
        PROTECT(tau = NEW_NUMERIC(1));
        xlambda = NUMERIC_POINTER(lambda);
        xtgrid = NUMERIC_POINTER(tgrid);
        xT2M = NUMERIC_POINTER(T2M);
        xNi = NUMERIC_POINTER(Ni);
        xNT = NUMERIC_POINTER(NT);
        xtau = NUMERIC_POINTER(tau);
        GetRNGstate();
        if(xlambda[0] != 0)
        {
                while(1)
                {
                        EVar = rexp(xlambda[0]);
                        sign = sign + EVar;
                        if (sign > xT2M[0])
                        {
                                break;
                        }
                        xtau = Realloc(xtau, i+1, double);
                        xtau[i] = sign;
                        i = i+1;
                        for(j; j < ltgrid;j++)
                        {
                                if (xtgrid[j] < sign)
                                {
                                        xNi[j] = xNT[0];
                                }
                                {
                                        break;
                                }
                        }
                        xNT[0] = xNT[0] + 1;
                }
                for(j;j < ltgrid;j++)
                {
                        xNi[j] = xNT[0];
                }
        }
        PutRNGstate();
        UNPROTECT(6);
        return tau;
}

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to