Programación gaussiana
{
int i, j, k, l, ll, irow, icol
Double big,pivinv,dum
int ipiv[50], indxr[50], indxc[50];
for(j = 0; j lt= n-1 ; j )
{
ipiv[j]= 0;
}
for(I = 0; ilt= n - 1; i )
{
grande = 0.0;
for(j = 0; j lt= n-1; j )
{
if(ipiv[j]!=1)
{
for(k = 0; k lt= n-1; k )
{
if(ipiv[k]==0)
{
if(fabs(a[j * n k ] ) gt; = grande)
{
grande = fabs(a[j * n k]);
irow = j;
icol = k;
}
else if(ipiv[k] gt; 1)
{
cout lt lt " Matriz Singular";
}
}
}
}
}
ipiv[icol]= ipiv[icol] 1;
if (irow!=icol)
{
for(l = 0; l lt = n-1; l )
{
dum =(a[irow * n l]);
a[irow * n l]= a[icol * n l];
a[icol * n l]= dum;
}
dum = b[irow];
b [ irow]= b[icol];
b[icol]= dum;
}
indxr[I]= irow;
indxc[I]= icol;
if(a[icol*n icol]==0.0)
{
cout lt lt" matriz singular.
”;
}
PIV inv = 1.0/(a[icol * n icol]);
a[icol * n icol]= 1.0;
for(l = 0; l lt= n-1; l )
{
a[icol * n l]= a[icol * n l]* PIV inv;
}
b[icol]= b[icol]* PIV inv;
for(ll = 0; ll lt= n-1 ;ll )
{
if (ll!=icol)
{
dum = a[ll * nicol];
a[ll * nicol]= 0.0
for(l = 0; l lt= n-1; l )
{
a[ll * n l]= a[ll * n l]-a[icol * n l]* dum;
}
b[ll]= b[ll ]-b[icol]* dum;
}
}
}
for(l = n-1; l lt =0; l -)
{
si(indxr[l]!=indxc[l])
{
para (k = 0; k lt = n-1; k )
{
dum = a[k * n indxr[l]];
a [k * n indxr[l]]= a[k * n indxc[l]];
a[k * n indxr[l]]= dum;
}
}
}
}