且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

简单的 3x3 矩阵逆代码 (C++)

更新时间:2022-10-14 18:41:09

为什么不尝试自己编写代码?把它当作一个挑战.:)

对于 3×3 矩阵


(来源:
(来源:wolfram.com)

我假设你知道矩阵的行列式 |A|是.

图像 (c) Wolfram|Alphamathworld.wolfram (06-11-09,22.06)

What's the easiest way to compute a 3x3 matrix inverse?

I'm just looking for a short code snippet that'll do the trick for non-singular matrices, possibly using Cramer's rule. It doesn't need to be highly optimized. I'd prefer simplicity over speed. I'd rather not link in additional libraries.

Why don't you try to code it yourself? Take it as a challenge. :)

For a 3×3 matrix


(source: wolfram.com)

the matrix inverse is


(source: wolfram.com)

I'm assuming you know what the determinant of a matrix |A| is.

Images (c) Wolfram|Alpha and mathworld.wolfram (06-11-09, 22.06)