Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mat: Should Factorization routines check for the condition number? #750

Closed
btracey opened this issue Nov 9, 2016 · 9 comments
Closed

mat: Should Factorization routines check for the condition number? #750

btracey opened this issue Nov 9, 2016 · 9 comments
Labels
stability affects API stability

Comments

@btracey
Copy link
Member

btracey commented Nov 9, 2016

It may be that factorization routines should check the condition number and return an error. This would make the failure happen earlier. For example, when using chol.Factorize(), and then SolveCholesky.

In most cases we cannot find the condition number before doing the factorization (since factorizing is how one frequently finds the condition number), but we can compute the condition number (like we already do) and return an ErrCond.

@vladimir-ch vladimir-ch transferred this issue from gonum/matrix Dec 9, 2018
@vladimir-ch vladimir-ch changed the title matrix/mat64: Should Factorization routines check for the condition number? mat: Should Factorization routines check for the condition number? Dec 9, 2018
@btracey btracey added the stability affects API stability label Mar 30, 2019
@kortschak
Copy link
Member

It's not clear to me how this would work better than what we have. The factorisation routines that we have that can fail return a boolean indicating success. Those that cannot do not. If the routine fails it should not be used, and the condition number can be obtained from the Cond method if the factorisation has calculated that. There may be places where the condition number could be used earlier in solvers (some of these are marked with TODOs), but these are not API-changing changes.

Are you suggesting the success booleans be replaced with error returns that are Condition? I'm not sure that makes things simpler.

@kortschak
Copy link
Member

ping

@btracey
Copy link
Member Author

btracey commented Jun 4, 2019

That was my thought. It's mostly about future-proofing. For example, if we switched to an algorithm that also finds the set of vectors that cause that condition number (I know some of them exist, but don't know the runtime details). Or with respect to a future errors package, it might be nice to implant more context. In the map/type assignment case, there's no extra information, it is or it isn't. In the factorization there's plausibly more information (most notably the condition number). An error type future-proofs against a lot of changes, a boolean doesn't, especially if the future is going to look like:

ok := chol.Factorize(a)
if !ok {
return chol.Cond()
}
(or something like that)

@kortschak
Copy link
Member

OK

@btracey
Copy link
Member Author

btracey commented Jun 4, 2019

I mean, it's not clear the benefit is there, I was just explaining the thought.

@kortschak
Copy link
Member

We need a decision one way or the other though.

@btracey
Copy link
Member Author

btracey commented Jun 4, 2019

It sounds like you still lean toward the boolean version?

@btracey
Copy link
Member Author

btracey commented Jun 4, 2019

Looking at the methods, it seems like the ok system is much more in line with the existing algorithms, for instance we don't compute the condition number if the matrix is singular. The error comes when actually solving the system. It seems like the current design is the most natural. As mentioned above, if you want to check on the condition number when the matrix is non-singular, you can do that. If you do not wish to (for instance printing components of the matrix), then it's not really an error to factorize it (even though some of the numbers could be crazy). Seems better to stick with the API that's natural for the algorithm we have.

@btracey btracey closed this as completed Jun 4, 2019
@kortschak
Copy link
Member

It sounds like you still lean toward the boolean version?

Yep. With that we can be free with API. Even though error contents should not be relied on, they are (we do in tests for example), so making error returns a thing makes that more constrictive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stability affects API stability
Projects
None yet
Development

No branches or pull requests

2 participants