There is a way to do that already. If you know that A is symmetric, you can do eigfact(Symmetric(A)), bypass the check for symmetry and go directly to the symmetric solver. This method should of course always return a real result so the alternative solution is: let eigfact(StridedMatrix) always return a complex solution and eigfact(Symmetric) return real solution.
2014-01-29 Milan Bouchet-Valat <[email protected]> > Le mercredi 29 janvier 2014 à 13:42 +0100, Andreas Noack Jensen a > écrit : > > The main problem is that it cannot really be determined before whether the > eigen solution is real or complex before the calculation is over in > contrast to the `sqrt` case. I think it would be a little annoying to get a > complex result from a symmetric matrix. Like if > > julia> sqrt(4.0) > > 2.0 + 0.0im > > Yeah, I have cases where I know I have a symmetric matrix and I expect a > Real result. Though, since this means the caller knows in advance the > expected type of the result, why not provide a way to pass this > information? This could be an argument specifying whether to return a Real(if > not possible, throw an error), or a completely separate function. > > This would ensure type stability, a better performance (no need to create > a Complex with a null imaginary part), and some additional safety (one > would need to use convert(Real, ...) to get an error if the result is not > a real, and probably some people will simply call real() and get wrong > results if the result is a "true" complex). > > > Regards > -- Med venlig hilsen Andreas Noack Jensen
