Lud
LU decomposition is the first step in a method used to solve a system of linear equations, where a matrix representing one of the known values is split into a lower and upper triangular matrix.
For e.g., a linear equation system A.x = z can be split into L U x = z, where L and U are the lower and upper triangular matrices which can be solved as y = U x = L-1 z and x = U-1 y
Source code snippet int size = 32; float *a = malloc(size * size * sizeof(float)); float sum;for (i=0; i < size; i++){ for (j=i; j < size; j++){ sum=a[i*size+j]; for (k=0; k < i; k++) sum -= a[i*size+k]*a[k*size+j]; a[i*size+j]=sum; } for (j=i+1;j < size; j++){ sum=a[j*size+i]; for (k=0; k < i; k++) sum -=a[j*size+k]*a[k*size+i]; a[j*size+i]=sum/a[i*size+i]; } }}