I wrote an article titled “Computing the Determinant of a Matrix Using Gaussian Elimination to Row Echelon Form with C#” in the August 2025 edition of Microsoft Visual Studio Magazine. See https://visualstudiomagazine.com/articles/2025/08/19/computing-the-determinant-of-a-matrix-using-gaussian-elimination-to-row-echelon-form-with-csharp.aspx.
One of the fundamental operations in machine learning is computing the inverse of a square matrix. But not all matrices have an inverse. The most common way to check if a matrix has an inverse or not is to compute a value called the determinant of the matrix. If the determinant of a matrix is 0, the matrix does not have an inverse. Any other value of the determinant means the source matrix does have an inverse.
There are several algorithms that can be used to compute the determinant of a matrix. One of the simplest techniques is called Gaussian elimination to row echelon form. My article presents a complete code implementation of computing the determinant of a matrix, using the row echelon form technique (aka Gaussian elimination), with the C# language.
The output of the demo program is:
Begin matrix determinant using Gaussian elimination to row echelon form Source matrix: 2.0 9.0 1.0 8.0 Determinant = 7.0000 Source matrix: 5.0 9.0 7.0 3.0 8.0 -1.0 -2.0 1.0 6.0 Determinant = 234.0000 Source matrix: 1.0 -4.0 3.0 0.0 2.0 8.0 6.0 -1.0 9.0 7.0 5.0 -1.0 -1.0 0.0 2.0 3.0 Determinant = -1103.0000 Source matrix: 1.0 4.0 3.0 0.0 2.0 8.0 6.0 0.0 9.0 7.0 5.0 1.0 -1.0 0.0 -2.0 -3.0 Determinant = 0.0000 End demo
The first three matrices have an inverse because their determinant is not 0. The last matrix does not have an inverse.
In machine learning, there are several algorithms that require computing the inverse of a matrix. One common example is kernel ridge regression using kernel matrix inverse training. In such situations, you usually want to check if the matrix involved has an inverse by computing the determinant of the matrix. If the determinant is 0, then the matrix does not have an inverse and you must use an alternative training technique, typically stochastic gradient descent.

I love old 1950s science fiction movies, even though objectively, most of these movies aren’t very good. For example, in “Beginning of the End” (1957), U.S. Department of Agriculture experiments with radioactive isotopes to grow large vegetables lead to automobile-sized grasshoppers that run amok in Chicago. And in “Them!” (1954), desert ants that live near atomic test sites evolve into automobile-sized ants.
I sometimes entertain myself by using AI text-to-image tools to design road signs inspired by the old science fiction movies I like so much.


.NET Test Automation Recipes
Software Testing
SciPy Programming Succinctly
Keras Succinctly
R Programming
2026 Visual Studio Live
2025 Summer MLADS Conference
2025 DevIntersection Conference
2025 Machine Learning Week
2025 Ai4 Conference
2025 G2E Conference
2025 iSC West Conference
You must be logged in to post a comment.