如何在TCL脚本中代码3 x 3矩阵的代码?
我发现在 tcl 中编码 3x3 矩阵的逆矩阵很困难。我们真的需要包来编码矩阵吗?我需要用最简单的编码对以下部分进行清晰的解释 1.如何创建矩阵? 2.如何求行列式? 3.如何求它的逆?
I'm finding difficulty in coding for inverse of a 3x3 matrix in tcl. do we really need packages to code for matrix , i need clear explanation for the following parts with minimal simpler coding
1.how to create matrix ?
2.how to find determinant?
3.how to find inverse of it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们不需要包——毕竟它们只是 Tcl 代码——但有时它们确实简化了很多事情。
矩阵在 Tcl 中表示为数字列表的列表;这是自然的表现。把它们想象成这样(这是行主形式):
但是可以像这样重写(这只是空白的改变,并不重要):
反转这样一个矩阵的代码是 Tcler 的 Wiki:
这是 Wiki 页面的代码,保存在此处,以防万一页面被编辑掉(并使用优化的
_Cofactor3
)。We don't need packages — they're just Tcl code after all — but they do simplify things quite a bit sometimes.
Matrices are represented in Tcl as lists of lists of numbers; it's the natural representation. Think of them being like this (which is row-major form):
But that can be rewritten like this (it's just a change of whitespace, which isn't significant):
The code to invert such a matrix is on the Tcler's Wiki:
This is the code from the Wiki page, saved here in case the page gets edited away (and using the optimised
_Cofactor3
).