Calculates the permanent of a matrix.