Note that there are some explanatory texts on larger screens.

plurals
  1. POArgument of type float **a in a subroutine
    primarykey
    data
    text
    <p>I have an argument in my subroutine defined as <code>float **a</code>.<br> How can I pass this to the function for a 2D array?</p> <p>EDIT: I have included the associated subroutine.</p> <pre><code>#include &lt;math.h&gt; #define NRANSI #include "nrutil.h" #define SWAP(a,b) {temp=(a);(a)=(b);(b)=temp;} void gaussj(float **a, int n, float **b, int m) { int *indxc,*indxr,*ipiv; int i,icol,irow,j,k,l,ll; float big,dum,pivinv,temp; indxc=ivector(1,n); indxr=ivector(1,n); ipiv=ivector(1,n); for (j=1;j&lt;=n;j++) ipiv[j]=0; for (i=1;i&lt;=n;i++) { big=0.0; for (j=1;j&lt;=n;j++) if (ipiv[j] != 1) for (k=1;k&lt;=n;k++) { if (ipiv[k] == 0) { if (fabs(a[j][k]) &gt;= big) { big=fabs(a[j][k]); irow=j; icol=k; } } else if (ipiv[k] &gt; 1) nrerror("gaussj: Singular Matrix-1"); } ++(ipiv[icol]); if (irow != icol) { for (l=1;l&lt;=n;l++) SWAP(a[irow][l],a[icol][l]) for (l=1;l&lt;=m;l++) SWAP(b[irow][l],b[icol][l]) } indxr[i]=irow; indxc[i]=icol; if (a[icol][icol] == 0.0) nrerror("gaussj: Singular Matrix-2"); pivinv=1.0/a[icol][icol]; a[icol][icol]=1.0; for (l=1;l&lt;=n;l++) a[icol][l] *= pivinv; for (l=1;l&lt;=m;l++) b[icol][l] *= pivinv; for (ll=1;ll&lt;=n;ll++) if (ll != icol) { dum=a[ll][icol]; a[ll][icol]=0.0; for (l=1;l&lt;=n;l++) a[ll][l] -= a[icol][l]*dum; for (l=1;l&lt;=m;l++) b[ll][l] -= b[icol][l]*dum; } } for (l=n;l&gt;=1;l--) { if (indxr[l] != indxc[l]) for (k=1;k&lt;=n;k++) SWAP(a[k][indxr[l]],a[k][indxc[l]]); } free_ivector(ipiv,1,n); free_ivector(indxr,1,n); free_ivector(indxc,1,n); } #undef SWAP #undef NRANSI /* (C) Copr. 1986-92 Numerical Recipes Software ("&gt;. */ </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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