I have been tinkering with this for a few hours and even with any examples can not find a reason for the Seg fault I'm getting, The code is all the way at the bottom of the post.

I am still new to C after a long python stint. I am trying to implement a jacobian algorithm to find the solution to a system of equations.

the header of the Jacobi dunction is commented right now to only take the array, and the length(it is assumed to be square)

the program dies on a segfault, running gdb gave me that it dies right at

when i started with this program I hardcoded A right into the function and it went through no problems so this must be with the way im taking in and handling A.Code:aInv[xCounter][xCounter] = 1.0/A[xCounter][xCounter];

Im sure the solution isnt terribly difficult but i've exhausted any similar examples I could find and hopefully someone here can offer guidance.

Code:#include <stdio.h> #include <math.h> #include <stdlib.h> int Jacobi(double **A/*,double *b*/,int n/*,double *xo,double tol,int MaxIt*/){ /* USAGE:its = Jacobi(A,b,n,xo,tol,MaxIt); INPUTS:A coefficient matrix for linear system b right-hand side vector n number of equations xo vector containing initial guess tol error tolerance-between successive approximations MaxIt maximum number of iterations OUTPUT: its No.of iterations performed(return-1 if max exceeded) xo approximate solution */ breakpt(); int iterCount = 0; int i = 0; int j = 0; double tempDouble = 0; /*First we find A^-1 */ double aInv[n][n]; int xCounter = 0; int yCounter = 0; double lower[n][n]; double upper[n][n]; while(yCounter < n){ xCounter = 0; while(xCounter < n){ if(yCounter == xCounter){ printf("%f - a number",&A[xCounter][xCounter]); aInv[xCounter][xCounter] = 1.0/A[xCounter][xCounter]; lower[xCounter][xCounter] = 0; upper[xCounter][xCounter] = 0; } else{ aInv[xCounter][yCounter] = 0; if(xCounter < yCounter){ lower[xCounter][yCounter] = A[xCounter][yCounter]; upper[xCounter][yCounter] = 0; } else{ upper[xCounter][yCounter] = A[xCounter][yCounter]; lower[xCounter][yCounter] = 0; } } xCounter++; } yCounter++; } xCounter = 0; PrintArray(aInv,2,"inverse"); PrintArray(lower,2,"lower"); PrintArray(upper,2,"upper"); /* while (counter < MaxIt){ }*/ } int main(int argc, char *argv[]){ printf("GOT HERE"); double a[2][2] = {2,3,5,7}; Jacobi(&a,2); } /*Prints a 2d square array of double, for debugging purposes*/ void PrintArray(double** Arr, int size, char* name){ int counterX = 0; int counterY = 0; printf("Printing %s Array...",name); while(counterY < size){ while(counterX < size){ printf("%f",Arr[counterX][counterY]); counterX++; } printf("\n"); counterY++; } } int breakpt(){ return 1; }