Dr. Eaton,

While working with the eig() function in octave (all version that I am

awared of), I noticed that the computed eigenvalues and their

corresponding eigenvectors are sorted in an ascending order. This also

happens with MatLab. I am wondering if it is possible to add a routine in

the eig() function to return the eigenvalues and the corresponding

eigenvectors in a descending order, for the next release of octave. To

make this function compatible with MatLab's eig function, make the

descending order feature as part of the OPT switch, i.e. when OPT=d, the

returned eigenvalues and their corresponding eigenvectors are sorted in a

descending order.

I know that sorting can be done after one has computed the eigenvalues and

their corresponding eigenvectors. As a matter of fact, I usually sort the

eigenvalues and their respective eigenvectors in a descending order with

the following macros:

function [v,d] = eigsort (x)

length = is_square (x);

if !(length)

error ('Input argument is not a square matrix!\n');

end;

[v,d] = eig (x);

[dd,ix] = sort (-diag (d));

for i=1:length

d(i,i) = - dd(i);

end;

v = v(:,ix)

endfunction

If sorting the eigenvalues and their corresponding eigenvectors in the

eig() function is not complicated and can speed up the process, wouldn't

it be better to add the sorting algorithm as an additional OPT feature in

the eig function instead of the above macros?

Thank you very much for your understanding.

--

[hidden email]