Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

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

DZone's Guide to

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

·
Free Resource

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
 adrianboeing.blogspot.com
 www.adrianboeing.com
 */

#include 
 
  

void PrintMatrix(double **mat, int m, int n) {
    for (int j=0;j
  
   0;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
   
  
 
Topics:

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}