Matrix Inversion using C#

I wrote an article titled “Matrix Inversion using C#” in the July 2016 issue of Microsoft’s MSDN Magazine. See

Matrix inversion isn’t a very thrilling topic, but there are dozens of important computer science algorithms that require matrix inversion. I’ve always been curious about why the .NET Framework doesn’t have a matrix inversion function.


Anyway, in the article I explain what matrix inversion is, and then present code that uses “Crout’s Algorithm” to find the inverse of a matrix in a rather surprising way.

In normal arithmetic, the inverse of a number z is a number that when multiplied by z gives 1. For example, if z = 3, the inverse of z is 1/3 = 0.33 because 3 * (1/3) = 1.

Matrix inversion extends this idea. The inverse of an nxn (called a “square matrix” because the number of rows equals the number of columns) matrix m is a matrix mi such that m * mi = I where I is the identity matrix (1.0s on the diagonal, 0.0s elsewhere).

This entry was posted in Machine Learning. Bookmark the permalink.