Re: [Rd] Catching errors from solve() with near-singular matrices

2012-12-12 Thread David Sterratt
Dear all, many thanks to Jon & Ravi for their help on this, and apologies if r-help would have been a more appropriate forum. On Tue, 2012-12-11 at 15:43 +, Jon Clayden wrote: > Strategy 1: Some code like this: >if (det(X) < epsilon) { > warning("Near singular

Re: [Rd] Catching errors from solve() with near-singular matrices

2012-12-12 Thread Ravi Varadhan
M To: r-devel@r-project.org Subject: [Rd] Catching errors from solve() with near-singular matrices Dear all, The background is that I'm trying to fix this bug in the geometry package: https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1993&group_id=1149&atid=4552 Bo

Re: [Rd] Catching errors from solve() with near-singular matrices

2012-12-11 Thread Jon Clayden
Dear David, I can think of two strategies for dealing with this problem: > > Strategy 1: Some code like this: >if (det(X) < epsilon) { > warning("Near singular matrix") > return(NULL) >} >return(solve(X)) This solution is probably the easiest one to take, but to match sol

[Rd] Catching errors from solve() with near-singular matrices

2012-12-11 Thread David Sterratt
Dear all, The background is that I'm trying to fix this bug in the geometry package: https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1993&group_id=1149&atid=4552 Boiled down, the problem is that there exists at least one matrix X for which det(X) != 0 and for which solve(X) fails