The permanent of matrix(1:9, 3) would then just be:
install.packages("permute"); library(permute)
A<-matrix(1:9, 3)
# Error: sum( apply( allPerms(1:3), 1, function(r) prod( A[1:3, r]) ) )
The allPerms function seems to leave out the original vector, hence the need for one of Ben Bolker's corrections and I should have used cbind to construct the indices for the items of A:
sum( apply( rbind(1:3,allPerms(1:3)), 1,
function(r) prod( A[cbind(1:3, r)]) ) )
The fact that these values are all positive and there is no subtraction suggests a reason why this "naive" implementation of that definition is not recommended.
A <- matrix(1:16,4)
sum( apply( rbind(1:4,allPerms(1:4)), 1,
function(r) prod( A[cbind(1:4, r)]) ) )
#[1] 55456