Is there a built-in function in Matlab to determine if a permutation is even or odd? -


variants of question have been crossposted mathematics stack exchange , computational science stack exchange. additional answers may found @ these other sites.

this question related posed @ getting mapping permutation in matlab . title pretty says all. know if there built-in function in matlab determining if permutation represented vector or odd. example, [2 1 4 3 5] permutation of identity permutation [1 2 3 4 5] because requires number of swaps 1 vector other. seems kind of thing people might want , there might built-in function for. people have posted quite long matlab files on web accomplish this. if matlab give me permutation matrix, take determinant of matrix, haven't figured out how that, nor know if there's quick way.

i don't think there built in function this. has simple , efficient solution: sign should determinant of permutation matrix vector.

a = [2 1 4 3 5]; = speye(length(a)); sign = det(i(:,a)); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -