[Rcpp-devel] pnorm/qnorm?
Dirk Eddelbuettel
edd at debian.org
Fri Sep 7 19:19:13 CEST 2012
On 7 September 2012 at 12:07, Rodney Sparapani wrote:
| On 09/07/2012 11:53 AM, Dirk Eddelbuettel wrote:
| > As a general, looking at the unit test files can be helpful. Here is one for qnorm:
| >
| > "runit_qnorm_prob" = list(
| > signature( x = "numeric" ),
| > '
| > NumericVector xx(x) ;
| > return List::create(_["lower"] = qnorm( xx, 0.0, 1.0 ),
| > _["upper"] = qnorm( xx, 0.0, 1.0, false));
| > ')
| >
| > Ie you can just call 'pnorm', 'qnorm', ...
| >
| > Dirk
|
| Hi Dirk:
|
| Well, I assumed as much. But, here's what I see...
|
|
| str <- '
| double a=as<double>(arg1), b=as<double>(arg2);
^^^^^^^^^^^^^^^^
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
|
| return wrap(qnorm(a, b, 1.));
| '
|
| check2 <- cxxfunction(signature(arg1="numeric", arg2="numeric"), str,
| plugin="Rcpp")
|
| #check2(0.5, 0.5)
|
| 33: return wrap(qnorm(a, b, 1.));
| 34:
| 35: END_RCPP
| 36: }
| 37:
| 38:
| Error in compileCode(f, code, language = language, verbose = verbose) :
| Compilation ERROR, function(s)/method(s) not created!
| file33b64e743def.cpp: In function 'SEXPREC* file33b64e743def(SEXPREC*,
| SEXPREC*)':
| file33b64e743def.cpp:33: error: no matching function for call to
| 'qnorm5(double&, double&, double)'
| make: *** [file33b64e743def.o] Error 1
| In addition: Warning message:
| running command '/opt/local/lib64/R/bin/R CMD SHLIB file33b64e743def.cpp
| 2> file33b64e743def.cpp.err.txt' had status 1
|
| Am I doing something stupid? Thanks
| --
| 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
More information about the Rcpp-devel
mailing list