Computational Science People:
I originally posed this as part of a question at https://math.stackexchange.com/questions/379809/is-there-a-name-for-this-function-parity-of-a-finite-sequence . The title pretty much says it all. Given a finite sequence of real numbers which I know are distinct, I want an easy way to compute whether it is an even permutation of an increasing sequence or an odd permutation of an increasing sequence. For example, $(5, 1.3, 8, 6, 10.5)$ is an even permutation of the increasing sequence $(1.3, 5, 6, 8, 10)$, so the answer is "even". $(2, 3, 5, 1)$ is an odd permutation of the increasing sequence $(1, 2, 3, 5)$, so the answer is "odd". I can get Matlab to give me a permutation vector, which for my first example would be $[2\ 1\ 4\ 3\ 5]$, but I cannot find a built-in function in Matlab to compute the sign of that permutation vector. If I could get Matlab to give me the permutation matrix, I could take the determinant of that matrix. People have posted quite long Matlab files on the Web to accomplish this, but I'm hoping I can avoid that. I would also be willing to use Maple.
Please no nitpicking or unconstructive comments, which are very common at Math Stack Exchange. I have less experience here, but I'm hoping people are more polite here.
Stefan (STack Exchange FAN)