Over a million developers have joined DZone.

Matrix operations: Gaussian elimination, Upper triangulization and Back-substitution example in C


A simple example of matrix operations (Gaussian elimination, Upper triangulization and Back-substitution) which can be used for solving systems of linear equations, or matrix inversion.

/** Gaussian elimination / Upper triangulization / Back-substitution example by Adrian Boeing


void PrintMatrix(double **mat, int m, int n) {
    for (int j=0;j0;p--) { //pivot backwards through all the rows
        for (int r=p-1;r>=0;r--) { //for each row above the pivot
            float multiple = mat[r][p]; //how many multiples of the pivot row do we need (to subtract)?
            for (int c=p-1;c

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}