#### Archived

This topic is now archived and is closed to further replies.

# Inverse of a Matrix

This topic is 6782 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey everyone. I need some help. I have forgotten how to inver a 4x4 matrix. I remember how to inver a 2x2 and a 3x3, but a 4x4 (or an NxN for that matter) uses a different algorithm. Any replies (relevant) will be greatly appreciated.

##### Share on other sites

Do you know how to do a Gauss-Jordan reduction on a matrix?

If so, in order to calculate the inverse of an n x n matrix you can simply create a new matrix with the n x 2n matrix with the right square being the matrix to be inverted and the left square being the n x n identity matrix, and perform a gaussian reduction on the matrix.

So if you want to invert:
[1 2 3]
[1 4 9]
[1 1 1]
create a matrix:
[1 2 3 1 0 0]
[1 4 9 0 1 0]
[1 1 1 0 0 1]
And perform the reduction and you''d get:
[1 0 0 -2.5 .5 3]
[0 1 0 4.0 -1 -3]
[0 0 1 -1.5 .5 1]

And the matrix
[-2.5 .5 3]
[4.0 -1 -3]
[-1.5 .5 1]
is the inverse.

##### Share on other sites
There''s source code for both Gaussian elimination and Cramer''s rule in this article from Intel:

AP-928 Streaming SIMD Extensions -Inverse of 4x4 Matrix

Oh, and don''t mind that it says SIMD Extensions, it shows how to do it with normal instructions as well.

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5
JoeJ
19

• 11
• 14
• 9
• 10
• 12
• ### Forum Statistics

• Total Topics
633003
• Total Posts
3009830
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!