python中的反矩阵(numpy/sympy)

发布于 2025-02-12 13:25:22 字数 431 浏览 1 评论 0原文

我有一个包含复数数字的顺序8*8的矩阵(a)。 我想计算该矩阵的倒数,因此我使用了np.linalg.inv(b)命令,但我有一个错误:

ufuntypeypeerror:无法将dtype('o')的ufunc'spt'输入施加到 dtype('float64')带有铸造规则'same_kind'

值得一提的是:

In [169]: type(A)
Out[169]: numpy.matrix
In [171]:type(A[0,0])
Out[171]: sympy.core.mul.Mul

如何计算该矩阵的倒数?我有点困惑,我应该在哪个图书馆搜索? numpy还是Sympy?由于矩阵类型为numpy,但是其组件是sympy。 谢谢

I have a matrix (A) of order 8*8 which contains complex numbers.
I would like to calculate the inverse of that matrix, so I used np.linalg.inv(b) command but I got an error:

UFuncTypeError: Cannot cast ufunc 'inv' input from dtype('O') to
dtype('float64') with casting rule 'same_kind'

It's worth to mention that:

In [169]: type(A)
Out[169]: numpy.matrix
In [171]:type(A[0,0])
Out[171]: sympy.core.mul.Mul

How can I calculate the inverse of that matrix? I have been a little confused, in which library should I search for? NumPy or SymPy? since the matrix type is NumPy however its component is SymPy.
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文