[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## output from eig() is complex?

**From**: |
Mario Storti |

**Subject**: |
output from eig() is complex? |

**Date**: |
Fri, 19 Jul 1996 11:49:33 -0300 |

I want to compute the eigenvalues of a symmetric matrix and sort them
as real numbers but I don't obtained the expected result. For
instance:
octave:7> A=rand(10);
octave:8> A=A+A';
octave:9> sort(eig(A))
ans =
0.0089208
0.5152296
-0.5608954
-0.6509429
0.9682804
1.5698353
1.9441555
-2.0148139
-2.5246725
9.5114825
My interpretation is that Octave is sorting the vector by absolute
value since this is the action for complex numbers, and in general the
result from the eig() operation should be a list of complex
numbers. However the result of the operation is strictly real:
octave:18> v=eig(A);
octave:19> whos
*** local user variables:
prot type rows cols name
==== ==== ==== ==== ====
wd real matrix 10 10 A
wd real matrix 10 1 v
I can solve the problem easily but I wonder if this is a sort of bug,
since splitting the sort(eig(A)) in two commands gives the correct
result:
octave:20> v=eig(A); sort(v)
ans =
-2.5246725
-2.0148139
-0.6509429
-0.5608954
0.0089208
0.5152296
0.9682804
1.5698353
1.9441555
9.5114825
This is also a source of incompatibility with Matlab, since with it I
can use always sort(eig(A)) for symmetric matrices.
Octave version: 1.1.1
internal variable: ok_to_lose_imaginary_part = warn
Mario
--
%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%
Mario Alberto Storti | Fax: (54)(42) 55.09.44 |
Grupo de Tecnologia Mecanica | Tel: (54)(42) 55.91.75 |
INTEC, Guemes 3450 - 3000 Santa Fe | http://venus.unl.edu.ar/ |
Argentina | Home: Gob. Vera 3161 |
Reply: address@hidden | (54)(42) 55.00.23 |

**output from eig() is complex?**,
*Mario Storti* **<=**