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:
permanent(rand(5,7) > 0.5)
A = sym('A',[2,3])
[ A1_1, A1_2, A1_3]
[ A2_1, A2_2, A2_3]
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.
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.
John D'Errico (2021). The permanent of any matrix (square or not) (https://www.mathworks.com/matlabcentral/fileexchange/63388-the-permanent-of-any-matrix-square-or-not), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!