Note that there are some explanatory texts on larger screens.

plurals
  1. POLabel used but not defined
    text
    copied!<p>I am trying to solve a linear systems of equations using LU decomposition followed by back substitution. However, in compiling it there is a problem, that states:</p> <pre><code>87:2: error: label ‘a’ used but not defined </code></pre> <p>Do you know what it means? Here is my program: </p> <pre><code>#include &lt;stdio.h&gt; #include &lt;math.h&gt; #include "nrutil.h" #include &lt;stdlib.h&gt; #define TINY 1.0e-20; void ludcmp(float **a, int n, int *indx, float *d) { int i,imax,j,k; float big,dum,sum,temp; float *vv; vv=vector(1,n); *d=1.0; for (i=1;i&lt;=n;i++) { big=0.0; for (j=1;j&lt;=n;j++) if ((temp=fabs(a[i][j])) &gt; big) big=temp; if (big == 0.0) nrerror("Singular matrix in routine ludcmp"); vv[i]=1.0/big; } for (j=1;j&lt;=n;j++) { for (i=1;i&lt;j;i++) { sum=a[i][j]; for (k=1;k&lt;i;k++) sum -= a[i][k]*a[k][j]; a[i][j]=sum; } big=0.0; for (i=j;i&lt;=n;i++) { sum=a[i][j]; for (k=1;k&lt;j;k++) sum -= a[i][k]*a[k][j]; a[i][j]=sum; if ( (dum=vv[i]*fabs(sum)) &gt;= big) { big=dum; imax=i; } } if (j != imax) { for (k=1;k&lt;=n;k++) { dum=a[imax][k]; a[imax][k]=a[j][k]; a[j][k]=dum; } *d = -(*d); vv[imax]=vv[j]; } indx[j]=imax; if (a[j][j] == 0.0) a[j][j]=TINY; if (j != n) { dum=1.0/(a[j][j]); for (i=j+1;i&lt;=n;i++) a[i][j] *= dum; } } free_vector(vv,1,n); } #undef TINY void lubksb(float **a, int n, int *indx, float b[]) { int i,ii=0,ip,j; float sum; for (i=1;i&lt;=n;i++) { ip=indx[i]; sum=b[ip]; b[ip]=b[i]; if (ii) for (j=ii;j&lt;=i-1;j++) sum -= a[i][j]*b[j]; else if (sum) ii=i; b[i]=sum; } for (i=n;i&gt;=1;i--) { sum=b[i]; for (j=i+1;j&lt;=n;j++) sum -= a[i][j]*b[j]; b[i]=sum/a[i][i]; } } int main(){ float a[3][3], c[3][3], b[3], d; int indx[3], i, j; a[1][1]=1.00; a[1][2]=0.80; a[1][3]=0.64; a[2][1]=1.00; a[2][2]=0.90; a[2][3]=0.81; a[3][1]=1.00; a[3][2]=1.10; a[3][3]=1.11; b[0]=erf(0.80); b[1]=erf(0.90); b[2]=erf(1.10); ludcmp(&amp;&amp;a, 3, indx, &amp;d); lubksb(&amp;&amp;a, 3, indx, b); for (i=0; i&lt;=3; i++) printf("%f", b[i]); return 0; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload