I'm trying to pass a 33*33 matrix as a parameter to a second function, but I keep getting a segmentation error. I think I am doing something obvioustly wrong, but I'm still learning and this is a big part of what I am struggling with.

/* This method determines the rank of a binary matrix. The matrix is reduced to upper triangular form using forward row operations and the operation is repeated using backward row operations in order to arrive at a matrix in triangular form. The rank is then taken to be the number of nonzero rows in the matrix. m = The size of the matrix (m*m) Matrix = The matrix which we want the rank of */ int MatrixRand(boolean **Matrix, int m) { int i, j, k, row, col, rank; boolean found, tmp; // Forward operations i = 1; // Step 1 while (i <= m-1) { // Step 2 found = TRUE; printf("StatisticalFunctions, before...\n"); if (Matrix[i][i] == 0) { printf("StatisticalFunctions, middel...\n"); // Search for a row with a leading 1 found = FALSE; k = i+1; while ((found == 0) && (k<=m)) { if (Matrix[k][i] == 1) { found = TRUE; // Swap all the elements of row i and k for (j = 1; j <= m; j++) { tmp = Matrix[i][j]; Matrix[i][j] = Matrix[k][j]; Matrix[k][j] = tmp; } } k++; } } printf("StatisticalFunctions, after...\n"); if (found == 1) { // Step 3 // Search for any subsequent row with a 1 in the ith column row = i+1; col = i; while (row <= m) { if (Matrix[row][col] == 1) { // XOR every element in this row with the ith row for (j = 1; j <= m; j++) { Matrix[row][j] = XOR(Matrix[row][j],Matrix[i][j]); } } row++; } } // if (found) // Step 4 i++; } // while // Backward operations i = m; // Step 1 while (i > 2) { found = TRUE; if (Matrix[i][i] == 0) { // Step 2 found = FALSE; k = i-1; while ((found == 0) && (k<=m)) { if (Matrix[k][i] == 1) { found = TRUE; // Swap all the elements of row i and k for (j = 1; j <= m; j++) { tmp = Matrix[i][j]; Matrix[i][j] = Matrix[k][j]; Matrix[k][j] = tmp; } } k--; } } if (found == 1) { // Step 3 row = i-1; col = i; while (row >= 1) { if (Matrix[row][col] == 1) { // XOR every element in this row with the ith row for (j = 1; j <= m; j++) { Matrix[row][j] = XOR(Matrix[row][j],Matrix[i][j]); } } row--; } } // if found // Step 4 i--; } // while // The rank of the matrix = the number of non-zero rows rank = 0; for (j = 1; j <= m; j++) { found = FALSE; for (k = 1; k <= m; k++) { if (Matrix[j][k] == 1) { found = TRUE; // The row is non-zero } } if (found == 1) { rank++; } } return rank; }; /* The focus of this test is the rank of the disjoint sub-matrices of the sequence. This test checks for linear dependance among fixed length substrings of the sequence. For implementation purposes, matrices of size 32*32 are used. n = The number of bits in the sequence */ boolean BinaryMatrixRankTest(long n) { int Fm, Fm1, i, j, rank, N, N2; double Xobs, P; boolean Matrix[33][33]; // The 0-index is left unused N = n/(1024); // Throw away bits that do not make up a full matrix if (n < 38912) { printf("Incorrect parameters. "); return FALSE; } N2 = 0; // Fill the matrix while (n >= 1024) { // 32*32 = 1024 for (i = 1; i <= 32; i++) { for (j = 1; j <= 32; j++) { Matrix[i][j] = getNextBoolean(); n--; } } printf("Before...\n"); rank = MatrixRand(Matrix,32); printf("After...\n"); switch (rank) { case 32 : Fm++; break; case 31 : Fm1++; break; } N2++; } printf("Precomputed N: %d\n",N); printf("Postcomputed N: %d\n",N2); Xobs = pow(Fm - 0.2888*N,2)/(0.2888*N) + pow(Fm1 - 0.5776*N,2)/(0.5776*N) + pow(N - Fm - Fm1 - 0.1336*N,2)/(0.1336*N); P = chidist(Xobs,2); if (P < 0.01) { // The sequence is non-random return FALSE; } else { // The sequence is random return TRUE; } };

I get an segmentation error the first time I try to access the array in the MatrixRand function. I would basically like to send the second function a pointer to the Matrix. What am I doing wrong? Please HELP!