Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement inv(::MatrixSymbol) #408

Closed
schneiderfelipe opened this issue Feb 3, 2021 · 1 comment
Closed

Implement inv(::MatrixSymbol) #408

schneiderfelipe opened this issue Feb 3, 2021 · 1 comment

Comments

@schneiderfelipe
Copy link

schneiderfelipe commented Feb 3, 2021

Hi, I think inv(A::MatrixSymbol) should be defined as A.inverse() (see here). Currently, the following error is thrown:

julia> using SymPy

julia> @syms n integer=true positive=true
(n,)

julia> Aₙ₋₁ = sympy.MatrixSymbol("Aₙ₋₁", n - 1, n - 1)
Aₙ₋₁

julia> Aₙ₋₁.I
    -1
Aₙ₋₁  

julia> inv(Aₙ₋₁)
ERROR: PyError ($(Expr(:escape, :(ccall(#= /home/schneider/.julia/packages/PyCall/tqyST/src/pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'NotImplementedError'>
NotImplementedError()
  File "/home/schneider/.local/lib/python3.8/site-packages/sympy/core/decorators.py", line 96, in __sympifyit_wrapper
    return func(a, b)
  File "/home/schneider/.local/lib/python3.8/site-packages/sympy/core/numbers.py", line 1774, in __truediv__
    return Number.__truediv__(self, other)
  File "/home/schneider/.local/lib/python3.8/site-packages/sympy/core/decorators.py", line 96, in __sympifyit_wrapper
    return func(a, b)
  File "/home/schneider/.local/lib/python3.8/site-packages/sympy/core/numbers.py", line 778, in __truediv__
    return AtomicExpr.__truediv__(self, other)
  File "/home/schneider/.local/lib/python3.8/site-packages/sympy/core/decorators.py", line 267, in _func
    return func(self, other)
  File "/home/schneider/.local/lib/python3.8/site-packages/sympy/core/decorators.py", line 136, in binary_op_wrapper
    return f(self)
  File "/home/schneider/.local/lib/python3.8/site-packages/sympy/matrices/expressions/matexpr.py", line 28, in __sympifyit_wrapper
    return func(a, b)
  File "/home/schneider/.local/lib/python3.8/site-packages/sympy/core/decorators.py", line 137, in binary_op_wrapper
    return func(self, other)
  File "/home/schneider/.local/lib/python3.8/site-packages/sympy/matrices/expressions/matexpr.py", line 160, in __rtruediv__
    raise NotImplementedError()

Stacktrace:
 [1] pyerr_check at /home/schneider/.julia/packages/PyCall/tqyST/src/exception.jl:62 [inlined]
 [2] pyerr_check at /home/schneider/.julia/packages/PyCall/tqyST/src/exception.jl:66 [inlined]
 [3] _handle_error(::String) at /home/schneider/.julia/packages/PyCall/tqyST/src/exception.jl:83
 [4] macro expansion at /home/schneider/.julia/packages/PyCall/tqyST/src/exception.jl:97 [inlined]
 [5] #109 at /home/schneider/.julia/packages/PyCall/tqyST/src/pyfncall.jl:43 [inlined]
 [6] disable_sigint at ./c.jl:446 [inlined]
 [7] __pycall! at /home/schneider/.julia/packages/PyCall/tqyST/src/pyfncall.jl:42 [inlined]
 [8] _pycall!(::PyCall.PyObject, ::PyCall.PyObject, ::Tuple{Sym}, ::Int64, ::Ptr{Nothing}) at /home/schneider/.julia/packages/PyCall/tqyST/src/pyfncall.jl:29
 [9] _pycall! at /home/schneider/.julia/packages/PyCall/tqyST/src/pyfncall.jl:11 [inlined]
 [10] #_#116 at /home/schneider/.julia/packages/PyCall/tqyST/src/pyfncall.jl:86 [inlined]
 [11] (::PyCall.PyObject)(::Sym) at /home/schneider/.julia/packages/PyCall/tqyST/src/pyfncall.jl:86
 [12] /(::Sym, ::Sym) at /home/schneider/.julia/packages/SymPy/Ja40T/src/mathops.jl:13
 [13] inv(::Sym) at ./number.jl:199
 [14] top-level scope at REPL[13]:1

EDIT: this might be related to #200 in general as well.

jverzani added a commit to jverzani/SymPy.jl that referenced this issue Feb 3, 2021
@jverzani
Copy link
Collaborator

jverzani commented Feb 3, 2021

Thanks! This was falling back to a generic definition that didn't work for this type.

jverzani added a commit that referenced this issue Feb 4, 2021
* close issues #408 (missing Base qualifier)

* bump version
@jverzani jverzani closed this as completed Jun 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants