[Edu-sig] Algebra + Python

Daniel Ajoy dajoy@softhome.net
Mon, 7 May 2001 18:14:44 -0500


On 7 May 01, at 12:01, edu-sig-request@python.org wrote:

> A simple way to compute the determinant is to add the signed 
> products of all permutations of matrix elements, choosing one 
> from each row (a total of row! possibilities).  ciphers.py is
> in charge of returning a list of all those possibilities 

Does that work for matrices 4x4 ? I ask because it didn't
work for me.

I have an algorithm that gives me the permutation in this
order for a 3 row matrix:

[[0 1 2] [0 2 1] [1 2 0] [1 0 2] [2 0 1] [2 1 0]]

and this for a 4 row matrix:

[[0 1 2 3] [0 1 3 2] [0 2 3 1] [0 2 1 3] [0 3 1 2] [0 3 2 1] [1 2 3 0] 
[1 2 0 3] [1 3 0 2] [1 3 2 0] [1 0 2 3] [1 0 3 2] [2 3 0 1] [2 3 1 0] 
[2 0 1 3] [2 0 3 1] [2 1 3 0] [2 1 0 3] [3 0 1 2] [3 0 2 1] [3 1 2 0] 
[3 1 0 2] [3 2 0 1] [3 2 1 0]]

Is that the same order you get with your algorithm.

For the 3 row matrix I change signs like this (using the
same order as above):

[1 -1 1 -1 1 -1]

and for the 4 row matrix something very similar:

[1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1]

Am I wrong in this step? using this this sequence of signs?

The funny thing is that it works nicely for matrices (2x2) and
(3x3).

Daniel