So the question appears to be: What do we do when encountering a non-hermitian matrix.
I have seen here and on github the options:
- check; return false
- check; throw.
- Never come into this situation: Only accept hermitian matrix types.
- Donât check, compute. Result is formally UB on non-hermitian matrices (but reasonable most of the time, and the set of
isposdef
matrices is open). Does the backend actually support this?
- check; compute A+transpose_conjugate(A); work on that (or do something that gives equivalent output).
- Always use the upper (resp. lower) triangular part.
Imho (1) makes no sense, (2) is not free; how expensive is the check compared to the computation? (3) is quite restrictive and someone should tell us how much cache-fiendlyness this loses, (4) makes some sense for users who know what they are doing (5) makes sense; but Iâd guess that the user should say explicitly that he wants this; (6) only makes sense as a possible implementation of (4) and only if it is faster than (5).
All in all I think that I am for (2) as default; and, if this gives a possible speedup over explicit handing by the user, options for (4) and (5). (6) can be achieved by wrapping in a symmetric type.
As various people said, (5) makes a lot of sense in many situations and is for real matrices and vectors equivalent to v'*A*v>0
. (the implementation is not actually required to compute A+A'
). (4) is what you probably want if your matrix is symmetric up to very small float-errors (only if it gives speedup over (5)).
To summarize (please clearly state what you are arguing for):
I argue for (2).
klacru argues for (5)
mohamed82008 argues for (5).
kristoffer.carlsson appears to argue for (1) (?).
juthohaegeman has not clarified yet what he argues for (1?).
Tamas_Papp thinks the discussion is silly.
Ralpha_Smith prefers (5), but thinks (1) is also acceptable if properly documented.
antoine-levitt argues for (3) (on github)
cortner argues for (5).
Now, why are so many people (including me) so strongly against (1)? Fundamentally, most yes/no questions allow the answers {yes | no | itâs complicated | [donât terminate]}.
Ask the converse: âisindefiniteâ. What are the reasonable answers to the question âis a small perturbation of the identity indefiniteâ?
Is anyone here arguing that such a matrix should be considered âindefiniteâ? I think not. Hence, when asking whether it is positive definite, we can only reasonably answer âitâs complicatedâ or âyesâ.
I think I prefer a version of âitâs complicatedâ in order to protect people who have not thought about what they actually want to check.
edits: keeping the list of people up-to-date.