Skip to content

Commit 88ae3d6

Browse files
authored
Update det.jl (#168)
det(M) fails if M is a 1x1 matrix, in which case it should just return the one element of that matrix. This might seem like a strange application of det but arises naturally when e.g. computing minors of a matrix.
1 parent 227989a commit 88ae3d6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/det.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ function LinearAlgebra.det(M::Matrix{<:AbstractPolynomialLike})
22
m = size(M)[1]
33
if m > 2
44
return sum((-1)^(i-1) * M[i,1] * LinearAlgebra.det(M[1:end .!= i, 2:end]) for i in 1:m)
5-
else
5+
elseif m == 2
66
return M[1,1] * M[2,2] - M[2,1] * M[1,2]
7+
else
8+
return M[1,1]
79
end
810
end

0 commit comments

Comments
 (0)