Determinant and permanent: Difference between revisions
Content added Content deleted
ReeceGoding (talk | contribs) (Added R.) |
ReeceGoding (talk | contribs) (→{{header|R}}: Simplified squareness check.) |
||
Line 2,274: | Line 2,274: | ||
{ |
{ |
||
stopifnot(is.matrix(A)) |
stopifnot(is.matrix(A)) |
||
n <- nrow(A) |
|||
⚫ | |||
n <- dimensions[1] |
|||
⚫ | |||
if(n < 1) stop("Matrix has a dimension of size 0.") |
if(n < 1) stop("Matrix has a dimension of size 0.") |
||
sum(sapply(combinat::permn(n), function(sigma) prod(sapply(1:n, function(i) A[i, sigma[i]])))) |
sum(sapply(combinat::permn(n), function(sigma) prod(sapply(1:n, function(i) A[i, sigma[i]])))) |