Skip to content

Commit 605551e

Browse files
authored
use SymPy's det, not generic one, close #256 (#257)
* use SymPys det, not generic one
1 parent ff91a83 commit 605551e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/matrix.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function getindex(s::AbstractArray{Sym}, i::Symbol)
1717
end
1818

1919

20-
# call a matrix method M[:det](). Matrix or vector arguments are converted via symmatrix
20+
# call a matrix method M.det(). Matrix or vector arguments are converted via symmatrix
2121
# though this may need to be done specially for some arguments that are passed in as collections
2222
global call_matrix_meth(object, meth, args...; kwargs...) = begin
2323
o = PyObject(object)
@@ -170,7 +170,7 @@ conj(a::Sym) = conjugate(a)
170170
eigvals(a::Matrix{Sym}) = [k for (k,v) in call_matrix_meth(a, :eigenvals)] # a[:eigevnals]() has multiplicity
171171
function eigvecs(a::Matrix{Sym})
172172
ds = call_matrix_meth(a, :eigenvects)
173-
out = Any[]
173+
out = Vector{Sym}[]
174174
for d in ds
175175
append!(out, d[3])
176176
end
@@ -179,6 +179,8 @@ end
179179
rref(a::Matrix{T}) where {T <: Integer} = N(rref(convert(Matrix{Sym}, a)))
180180
rref(a::Matrix{Rational{T}}) where {T <: Integer} = N(rref(convert(Matrix{Sym}, a)))
181181

182+
det(A::Matrix{T}) where {T <: Sym} = sympy.det(A)
183+
182184
"""
183185
Return orthogonal basis from a set of vectors
184186

test/tests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,13 @@ end
530530
@test applicable(sincos, x)
531531
@test sincos(x)[1] == sin(x)
532532

533+
# issue 256 det
534+
@vars rho phi theta real=true
535+
xs = [rho*cos(theta)*sin(phi), rho*sin(theta)*sin(phi), rho*cos(phi)]
536+
J = [diff(x, u) for x in xs, u in (rho, phi, theta)]
537+
det(J)
538+
539+
533540
end
534541

535542
@testset "generic programming, issue 223" begin

0 commit comments

Comments
 (0)