I have a simple question regarding pointers of the form **a. I have been trying to incorporate some external code into a program of mine, and one of the functions takes on a pointer like this as an argument. Furthermore, when the thing is used in the function, it is referred to as a two dimensional array. This is confusing to me, since I'm new to C. I'm looking for conceptual help here.

I've got the thing copied in properly, I think, but I don't know what preceisely to put in this argument slot. I've tried putting in the array, a pointer to the array, and a pointer to the pointer to the array. Everything either won't compile, or calling the function yields a segmentation fault.

I'm including the code, assuming that might help clarify things a bit. It's the first phase of a two part algorithm to get the eigenvalues and eigenvectors of a real symmetric matrix. This thing puts the matrix in a special form (tri-diagonal form) via similarity transforms.

Thanks!

Code:void tred2(int n, double **a, double d[], double e[]){ int l,k,j,i; float scale, hh, h, g, f; for (i=n; i>=2; i--){ l=i-1; h=scale=0.0; if(l>1){ for(k=1;k<=l;k++) scale +=fabs(a[i][k]); if(scale == 0.0) e[i]=a[i][l]; else{ for(k=1;k<=l;k++){ a[i][k] /= scale; h += a[i][k]*a[i][k]; } f=a[i][l]; g = (f >= 0.0 ? -sqrt(h) : sqrt(h)); e[i]=scale*g; h -= f*g; a[i][l]=f-g; f=0.0; for(j=1; j<=l; j++){ a[j][i]=a[i][j]/h; g=0.0; for(k=1;k<=j;k++) g += a[j][k]*a[i][k]; for(k=j+1;k<=l;k++) g += a[k][j]*a[i][k]; e[j]=g/h; f += e[j]*a[i][j]; } hh=f/(h+h); for(j=1;j<=1;j++){ f=a[i][j]; e[j]=g=e[j]-hh*f; for(k=1;k<=j;k++) a[j][k] -= (f*e[k]+g*a[i][k]); } } } else e[i]=a[i][j]; d[i]=h; } d[1]=0.0; e[1]=0.0; for(i=1;i<=n;i++){ l=i-1; if(d[i]){ for (j=1; j<=1; j++){ g=0.0; for(k=1;k<=l;k++) g += a[i][k]*a[k][j]; for(k=1;k<=l;k++) a[k][j] -= g*a[k][i]; } } d[i]=a[i][i]; a[i][i]=1.0; for(j=1;j<=l;j++) a[j][i]=a[i][j]=0.0; } }