Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 sympy 库的新手,我有一个相对简单的问题。我正在编写一个 3D 矢量,如下所示
from sympy.vector import CoordSys3D N = CoordSys3D('N') v = 1*N.i + 4*N.j + 5*N.k
例如,我想从其中一个基础访问标量:
命令 v[0] = 1 或 v[1] = 4。
使用Sympy可能吗?
您可以使用dot提取组件:
dot
In [57]: from sympy.vector import CoordSys3D, dot ...: N = CoordSys3D('N') ...: v = 1*N.i + 4*N.j + 5*N.k In [58]: v Out[58]: i_N + (4) j_N + (5) k_N In [59]: dot(v, N.j) Out[59]: 4