×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

solving AX=B matris in Vb 6.0

solving AX=B matris in Vb 6.0

solving AX=B matris in Vb 6.0

(OP)
Hello all
i need a module  for solving ( writing ) the matrix X in Vbasic 6.0

A X = B

thx a lot...

RE: solving AX=B matris in Vb 6.0

Function GaussElimPivot(a() As Double, b() As Double) As Boolean


' --------------------------------------------------
' Solves a system of linear equations with the
' Gaussian elimination.
'                              Kim Sivonen 28.6.2001
' --------------------------------------------------
'
' Partial pivoting is being used for to make the
' algorithm stable. This means that the order of the
' equations is changed so that the biggest values appear
' on the diagonal. New pivot is searched on each row.
'
' The equations are reordered by switching indexes
' in an index table.
'
' Parameters:
' A() = coifficient matrix
' B() = constant vector
'
' Return:
' Gauss_elim = 'true' tai 'false'
' B()       = solved values
'


   Dim i As Integer, j As Integer, k As Integer, n As Integer
   Dim D As Double, c As Double, x() As Double
   Dim Indeksi() As Integer
   
   n = UBound(b)
   
   ReDim Indeksi(1 To n)
   ReDim x(1 To n)
   
   ' format the index table
   For i = 1 To n
      Indeksi(i) = i
      x(i) = b(i)
   Next i

   ' elimination of the lower triangular matrix
   Dim Luku As Integer, E As Double, Suurin As Double
   
   For i = 1 To n - 1
      
      ' pivot is being searched and swithed
      D = a(Indeksi(i), i)
      Suurin = i
      For j = i + 1 To n
         E = a(Indeksi(j), i)
         If Abs(E) > Abs(D) Then
            D = E
            Suurin = j
         End If
      Next j
      Luku = Indeksi(i)
      Indeksi(i) = Indeksi(Suurin)
      Indeksi(Suurin) = Luku

      ' elimination
      For j = i + 1 To n
         c = a(Indeksi(j), i) / D
         For k = i To n
            a(Indeksi(j), k) = a(Indeksi(j), k) - c * a(Indeksi(i), k)
         Next k
         x(Indeksi(j)) = x(Indeksi(j)) - c * x(Indeksi(i))
      Next j
   Next i


   ' back substitution
   For i = n To 1 Step -1
      x(Indeksi(i)) = x(Indeksi(i)) / a(Indeksi(i), i)
      For j = i - 1 To 1 Step -1
         x(Indeksi(j)) = x(Indeksi(j)) - a(Indeksi(j), i) * x(Indeksi(i))
      Next j
   Next i
   
   For i = 1 To n
      b(i) = x(Indeksi(i))
   Next i

   GaussElimPivot = True

End Function

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources