[Rcpp-devel] pnorm/qnorm?
Jeffrey Pollock
jeffpollock9 at gmail.com
Mon Sep 10 17:41:26 CEST 2012
Try;
require(Rcpp)
require(inline)
check2 <- cxxfunction(signature(arg1 = "numeric", arg2 = "numeric"), '
NumericVector q(arg1);
double mean = as<double>(arg2);
double sd = 1.0;
return wrap(qnorm(q, mean, sd));
', plugin = "Rcpp")
output;
> check2 <- cxxfunction(signature(arg1 = "numeric", arg2 = "numeric"), '
+ NumericVector q(arg1);
+ double mean = as<double>(arg2);
+ double sd = 1.0;
+
+ return wrap(qnorm(q, mean, sd));
+ ', plugin = "Rcpp")
> check2(0.5, 0.5)
[1] 0.5
On Mon, Sep 10, 2012 at 4:35 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> On 10 September 2012 at 10:23, Rodney Sparapani wrote:
> | On 09/07/2012 12:19 PM, Dirk Eddelbuettel wrote:
> | > Make that Rcpp::NumericVector a = Rcpp::NumericVector(arg1); and
> things
> | > will just work.
> | >
> | > Would be nice if the compiler messahes could be more helpful... All
> sugar
> | > functions are vectorised, so you must feed them a vector (which, as we
> work
> | > with R, may well be of length 1 if you so choose....)
> | >
> | > Dirk
> |
> | Thank you Dirk! But, I seem to keep messing this up. Could you take a
> | look at this?
>
> Please look at the two emails I sent in this thread on Sep 7.
>
> Dirk
>
> |
> | require(Rcpp)
> | require(inline)
> |
> | str <- '
> | double x=as<double>(qnorm(as<NumericVector>(arg1),
> | as<NumericVector>(arg2), as<NumericVector>(1.))[0]);
> | return wrap(x);
> | '
> |
> | check2 <- cxxfunction(signature(arg1="numeric", arg2="numeric"), str,
> | plugin="Rcpp")
> |
> | check2(0.5, 0.5)
> |
> | ...
> |
> | 31: double x=as<double>(qnorm(as<NumericVector>(arg1),
> | as<NumericVector>(arg2), as<NumericVector>(1.))[0]);
> | 32: return wrap(x);
> | 33:
> | 34: END_RCPP
> | 35: }
> | 36:
> | 37:
> | Error in compileCode(f, code, language = language, verbose = verbose) :
> | Compilation ERROR, function(s)/method(s) not created!
> | file1a785d3ff187.cpp: In function 'SEXPREC* file1a785d3ff187(SEXPREC*,
> | SEXPREC*)':
> | file1a785d3ff187.cpp:31: error: no matching function for call to
> | 'as(double)'
> | make: *** [file1a785d3ff187.o] Error 1
> | In addition: Warning message:
> | running command '/opt/local/lib64/R/bin/R CMD SHLIB file1a785d3ff187.cpp
> | 2> file1a785d3ff187.cpp.err.txt' had status 1
> |
> | --
> | Rodney Sparapani, PhD Center for Patient Care and Outcomes Research
> | Sr. Biostatistician http://www.mcw.edu/pcor
> | 4 wheels good, 2 wheels better! Medical College of Wisconsin (MCW)
> | WWLD?: What Would Lombardi Do? Milwaukee, WI, USA
>
> --
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20120910/45c9a889/attachment.html>
More information about the Rcpp-devel
mailing list