Private Function ReductionUpTriangularForm(ByVal Matrix As Double(,)) _
As Double(,)
Dim i, j, k As Integer
For i = 0 To UBound(Matrix, 2) - 1
'
'Find the element of maximum magnitude
'
Dim MaxValueIndex As Double = i + 1
For j = i + 1 To UBound(Matrix, 1)
If Matrix(j, i) > Matrix(MaxValueIndex, i) Then
MaxValueIndex = j :
End If
Next
If Matrix(MaxValueIndex, i) <> 0 Then
'
'Interchange rows
'
Dim TempVector_Row(UBound(Matrix, 2)) As Double
For j = 0 To UBound(Matrix, 2)
TempVector_Row(j) = Matrix(MaxValueIndex, j)
Next
For j = 0 To UBound(Matrix, 2)
Matrix(MaxValueIndex, j) = Matrix(i, j)
Matrix(i, j) = TempVector_Row(j)
Next
'
'Compute the multiplier and make the elimination
'
For j = i + 1 To UBound(Matrix, 1)
Dim Multiplier As Double = Matrix(j, i) / Matrix(i, i)
For k = 0 To UBound(Matrix, 2)
Matrix(j, k) -= Multiplier * Matrix(i, k)
Next
Next
End If
Next
Return Matrix
End Function
--
▕▔▔▏ 伸 出 ◣
▕▓▓ 友 誼 的 雙 手
▄▄ 與 大 家 共 同
分 享 歡 樂 的 時 光
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.59.31.47
※ 編輯: collegeman 來自: 61.59.31.47 (05/20 01:53)