[Gambas-user] Long C routine

martin p cristia tercoide at ...67...
Thu Jan 30 16:58:28 CET 2014


Hi:

I need a way to keep the GUI alive while processing a EXTERNAL C routine:

Public Extern M8gauss(mfMatriz As Float[], vfX As Float[], vfTermns As 
Float[], lOrder As Long) As Long

wich is a Gaussian ecuations system solver, and can take up to 10minutes 
( 10^10 aritmetic operations).

Any help on doing this?
tnx in advance
I'll paste the actual C routine from the .SO

long M8gauss(double *matriz, double *x, double * ti, long n )
{

     if(n == 0)return 1;
     int i, i1, j, h, h1;
     //long ok = -1;
     //long contador = 0,i1,h1,h,i,j;
     double c1;
     // triangulacion
     for (i = 0;i<n;i++)
     {
         i1=i*n;

         if(matriz[i+i1] != 0)
         {
             for (j = (i + 1);j<n;j++)
             {
                 if(matriz[j+i1] != 0)
                 {
                     c1 = -matriz[j+i1] / matriz[i+i1];
                     for(h = i; h<n ; h++)
                     {
                         h1=h*n;
                         matriz[j+h1] += c1 * matriz[i+h1];

                     }
                     ti[j] = ti[j] + c1 * ti[i];
                 }
             }
         }
          else
             // exit returning the position of 0 element
              return i+i1;
     }

     // backward sustitucion
     double  p1;

     x[n-1] = ti[n-1] / matriz[n* n-1];

     for (i = n - 2;i>=0;i--)
     {
         p1 = 0;
         for (j = i + 1;j<n;j++)
             p1 += - x[j] * matriz[i+ j*n];

         p1 += ti[i];
         x[i] = p1 / matriz[i+i*n];
     }
     return -1;

}






More information about the User mailing list