# Permanent(n, R)ΒΆ

- n: PositiveInteger
- R: Join(Ring, CommutativeStar)

Permanent implements the functions *permanent*, the permanent for square matrices.

- permanent: SquareMatrix(n, R) -> R
`permanent(x)`

computes the permanent of a square matrix`x`

. The*permanent*is equivalent to the determinant except that coefficients have no change of sign. This function is much more difficult to compute than the*determinant*. The formula used is by`H`

.`J`

. Ryser, improved by [Nijenhuis and Wilf,`Ch`

. 19]. Note: permanent(`x`

) choose one of three algorithms, depending on the underlying ring`R`

and on`n`

, the number of rows (and columns) of`x:`

begin{items} item 1. if 2 has an inverse in`R`

we can use the algorithm of [Nijenhuis and Wilf,`ch`

.19,`p`

.158]; if 2 has no inverse, some modifications are necessary: item 2. if*n > 6*and`R`

is an integral domain with characteristic different from 2 (the algorithm works if and only 2 is not a zero-divisor of`R`

and*characteristic()$R ~= 2*, but how to check that for any given`R`

?), the local function*permanent2*is called; item 3. else, the local function*permanent3*is called (works for all commutative rings`R`

). end{items}