symengine / SymEngine.jl

Julia wrappers of SymEngine
MIT License
192 stars 43 forks source link

fix lu return type #257

Closed GiggleLiu closed 12 months ago

GiggleLiu commented 1 year ago

Before the fix

julia> @vars a b c d x y
(a, b, c, d, x, y)

julia> A = [a b; c d]
2×2 Matrix{Basic}:
 a  b
 c  d

julia> b = [x, y]
2-element Vector{Basic}:
 x
 y

julia> res = A \ b
ERROR: MethodError: no method matching adjoint(::Tuple{Matrix{Basic}, Matrix{Basic}, Matrix{Basic}})
Closest candidates are:
  adjoint(::Union{LinearAlgebra.QR, LinearAlgebra.QRCompactWY, LinearAlgebra.QRPivoted}) at ~/.julia/juliaup/julia-1.8.4+0.x64.linux.gnu/share/julia/stdlib/v1.8/LinearAlgebra/src/qr.jl:517
  adjoint(::Union{LinearAlgebra.Cholesky, LinearAlgebra.CholeskyPivoted}) at ~/.julia/juliaup/julia-1.8.4+0.x64.linux.gnu/share/julia/stdlib/v1.8/LinearAlgebra/src/cholesky.jl:558
  adjoint(::LinearAlgebra.LQ) at ~/.julia/juliaup/julia-1.8.4+0.x64.linux.gnu/share/julia/stdlib/v1.8/LinearAlgebra/src/lq.jl:138
  ...
Stacktrace:
 [1] \(x::Tuple{Matrix{Basic}, Matrix{Basic}, Matrix{Basic}}, y::Vector{Basic})
   @ Base ./operators.jl:629
 [2] \(A::Matrix{Basic}, B::Vector{Basic})
   @ LinearAlgebra ~/.julia/juliaup/julia-1.8.4+0.x64.linux.gnu/share/julia/stdlib/v1.8/LinearAlgebra/src/generic.jl:1110
 [3] top-level scope
   @ REPL[24]:1

After the fix

julia> res = A \ b
2-element Vector{Basic}:
 (x - b*(y - c*x/a)/(d - b*c/a))/a
           (y - c*x/a)/(d - b*c/a)
isuruf commented 12 months ago

Thanks