Question: Sorting Complex Numbers by Amplitude without losing the Phase

Hello everyone

I have a small, yet tricky question and hope someone knows a quick answer.

A calculation gives me a vector of say 10 complex numbers (floats). I want to store the amplitudes ( abs() ) and the phases ( argument() ) of these complex values in two seperate lists. Next, I want to sort the complex numbers by ascending amplitude, but I do not want to lose the phase belonging to each amplitude, for example:

[ampl3,ampl1,ampl2],[phase3,phase1,phase2] ------ sort() ------> [ampl1,ampl2,ampl3],[phase1,phase2,phase3]

So the 2nd List should be sorted as well, yet not by size. It should take over the order of the amplitudes list so that after sorting, I should still be able to "rebuild" any of the original complex numbers, just by multiplying entry x of list one with entry x of list two (and of course using exp() ).

I hope that this topic is of interest and say "thanks" for any help

 

Karl

 

Please Wait...