What are you trying to do exactly? Have you looked up ready well known algorithm for it? By quick look that seems to be O(n^3), which makes me think it can done faster.
Jussi On Fri, Nov 28, 2014 at 2:02 AM, martin p cristia <[email protected]> wrote: > Hi, is there any way to speed up this routine? > Thanks > > Fast Public Function solucionarXgauss(x As Float[], ti As Float[], > iOrden As Integer) As Integer > ' OK GAMBAS > > Dim c1 As Float > Dim i As Integer, j As Integer, a As Integer, b As Integer, ok As > Integer > Dim l As Integer, h As Integer, i1 As Integer, j1 As Integer > Dim p1 As Float, iTest As Integer, nTest As Integer > > contador = 0 > If iOrden = 0 Then Return 0 > ok = True > > 'usa el metodo de Gauss > 'debe ser cuadrada la matriz > ' triangulacion > itest = iorden / 100 > > For i = 0 To iOrden - 1 > > > 'This is to show the progress in the GUI > FMain.debugInfo("Resolviendo el sistema ", True, Format$(100 * > i / iorden, "0.00") & "%") > > If debanda(i, i) <> 0 Then > For j = i + 1 To iOrden - 1 > If debanda(j, i) <> 0 Then > c1 = - debanda(j, i) / debanda(i, i) > For h = i To iOrden - 1 > addbanda(j, h, c1 * debanda(i, h)) > > Next > ti[j] = ti[j] + c1 * ti[i] > End If > Next > Else > Return > l = i > If i = iOrden - 1 Or l > iOrden - 1 Then Return 0 ' el > sistema es incompatible > > Do > If debanda(l, i) <> 0 Then > For h = 0 To iOrden - 1 > addbanda(i, h, debanda(l, h)) > Next > ti[i] = ti[i] + ti[l] > Exit > Else > l = l + 1 > If i = iOrden - 1 Or l > iOrden - 1 Then Return 0 ' > el sistema es incompatible > End If > Loop > End If > > Next > ' sustitucion atrás > > x[iOrden - 1] = ti[iOrden - 1] / debanda(iOrden - 1, iOrden - 1) > For i = iOrden - 2 To 0 Step -1 > p1 = 0 > For j = i + 1 To iOrden - 1 > p1 = p1 - x[j] * debanda(i, j) > > Next > p1 = ti[i] + p1 > x[i] = p1 / debanda(i, i) > Next > Return ok > > End Function > > Fast Public Sub ABanda(ib As Integer, jb As Integer, valor As Float) > > > modCalculus.MatRigEst[ib * modEstru.ordmatrig + jb] = valor > > Return > > > End Sub > > DeBanda() and AddBanda() are similar > > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk > _______________________________________________ > Gambas-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/gambas-user > ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk _______________________________________________ Gambas-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/gambas-user
