Re: [Rcpp-devel] Detecting Singular Matrices in RcppArmadillo

2022-01-28 Thread Alex Ilich
Thanks! I'll use if(rcf <= std::numeric_limits::epsilon()) instead of rcf==0. On Fri, Jan 28, 2022 at 7:32 PM Dirk Eddelbuettel wrote: > > On 28 January 2022 at 13:25, Alex Ilich wrote: > | Thank you Neal and Dirk. Based on these comments I think using > arma::rcond > > Ah, yes, of course. Shoul

Re: [Rcpp-devel] Detecting Singular Matrices in RcppArmadillo

2022-01-28 Thread Dirk Eddelbuettel
On 28 January 2022 at 13:25, Alex Ilich wrote: | Thank you Neal and Dirk. Based on these comments I think using arma::rcond Ah, yes, of course. Should have remembered arma::rcond. | to get the reciprocal of the condition factor, and checking if that is zero | rather than the determinant may be t

Re: [Rcpp-devel] Detecting Singular Matrices in RcppArmadillo

2022-01-28 Thread Alex Ilich
Thank you Neal and Dirk. Based on these comments I think using arma::rcond to get the reciprocal of the condition factor, and checking if that is zero rather than the determinant may be the route to go. At least for this example that works. library(Rcpp) cppFunction(depends="RcppArmadillo", "Nume

Re: [Rcpp-devel] Detecting Singular Matrices in RcppArmadillo

2022-01-28 Thread Dirk Eddelbuettel
On 28 January 2022 at 09:16, Neal Fultz wrote: | There's an R object that has the machine precision, which could be a | reasonable threshold. | | .Machine$double.eps | | I believe there is a similar constant in the C++ standard library. | | You might also try checking the condition of the matri

Re: [Rcpp-devel] Detecting Singular Matrices in RcppArmadillo

2022-01-28 Thread Neal Fultz
There's an R object that has the machine precision, which could be a reasonable threshold. .Machine$double.eps I believe there is a similar constant in the C++ standard library. You might also try checking the condition of the matrix instead of the determinant, but you might take a performance h

[Rcpp-devel] Detecting Singular Matrices in RcppArmadillo

2022-01-28 Thread Alex Ilich
Hi, I have some code I've written to calculate regression parameters using ordinarily least squares using RcppArmadillo. This is meant to be performed iteratively over many small subsets (sliding window over spatial raster data) so I'd like to automatically detect when the regression can't be perfo