The permanent of any matrix (square or not)

The permanent of any matrix, square or not
Updated 20 Jun 2017

View License

There are codes on the FEX to compute the permanent of a matrix. One thing lacking is a tool with the capability to compute the permanent of a non-square matrix. This tool fills that gap. That was the ONLY reason I've posted this code, since there are already many tools on the FEX to compute a matrix permanent.

If you want a reference on the algorithm employed, all I can suggest is:

The demos I've provided are pretty exhaustive. And since permanent works on symbolic arrays, I've offered afew tests for them too to convince you the computations are correct. But here are some simple examples of use:

ans =

permanent(rand(5,7) > 0.5)
ans =

A = sym('A',[2,3])
A =
[ A1_1, A1_2, A1_3]
[ A2_1, A2_2, A2_3]
ans =
A1_1*A2_2 + A1_2*A2_1 + A1_1*A2_3 + A1_3*A2_1 + A1_2*A2_3 + A1_3*A2_2

For anyone who wants faster code, sorry. This is what it is. There are faster tools out there. permanent is pretty fast for matrices as large as 10x10, and is quite fast for smaller matrices. It does NOT use a recursive algorithm, but the fact is, it will need to compute the products of a lot of numbers for larger matrices.

ans =
Elapsed time is 1.199238 seconds.

Computation for larger matrices can become VERY slow, because this tool will begin to use large blocks of memory. Recursive algorithms can also be slow for large problems.

Cite As

John D'Errico (2024). The permanent of any matrix (square or not) (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2017a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Creating and Concatenating Matrices in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!



Version Published Release Notes