[Rcpp-devel] error handling for computational singularity

Dirk Eddelbuettel edd at debian.org
Sun Jul 7 06:28:16 CEST 2013


On 6 July 2013 at 18:56, Xiao He wrote:
| Hi dear listers,
| 
| Take the mock function below for an example. What would be the best way to
| handle computational singularity?

That is essentially a _statistical_ issue and not a Rcpp problem so that is
not really the right forum.

| #include <R.h>
| #include <stdio.h>
| #include <RcppArmadillo.h>
| // [[Rcpp::depends(RcppArmadillo)]]
| 
| using namespace Rcpp;
| using namespace arma;
| 
| RcppExport SEXP foo(SEXP X, SEXP Y){
| arma::mat x=Rcpp::as<arma::mat>(X), y=Rcpp::as<arma::mat>(Y);
| arma::mat output = arma::solve(x, y );
| return(wrap(output));
| }
| 
| 
| For instance, if I use the function on the dataset below, R would crash. I read
| the error handling section of the document in http://www.jstatsoft.org/v40/i08/
| paper, but I am not exactly sure what to do with my situation. Thank you in

Rcpp offers support for exception handling -- meaning that _you_ could decide
to throw an exception to signal to the user that his data is not right /
properly conditioned.  

See the Armadillo documentation to learn how to test rank of matrices
etc. You may also learn that sole() is for a matrix and a vector, not two
vectors.

Dirk


| advance for your help!
| 
| x = cbind(1:2, 1:2)
| .Call("foo", x, x)
| 
| 
| 
| ----------------------------------------------------------------------
| _______________________________________________
| 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
-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list