Categories
VB.NET

Транспониране на матрица във VB.NET

Функция на Visual Basic за транспониране на матрици.

Public Class Matrix
Public Shared Function mTranspose(ByVal m1(,) As Double)
Dim m2(m1.GetLength(1), m1.GetLength(0)) As Double
For i As Integer = 0 To m1.GetLength(0) - 1
For j As Integer = 0 To m1.GetLength(1) - 1
m2(j, i) = m1(i, j)
Next j
Next i
Return m2
End Function
End Class
view raw Matrix.vb hosted with ❤ by GitHub
Categories
VB.NET

Умножение на матрици във VB.NET

Функция на Visual Basic за умножение на матрици.

Public Class Matrix
Public Shared Function mMult(ByVal m1(,) As Double, ByVal m2(,) As Double)
Dim m3(m1.GetLength(0), m2.GetLength(1)) As Double
For i As Integer = 0 To m1.GetLength(0) - 1
For j As Integer = 0 To m1.GetLength(1) - 1
For k As Integer = 0 To m2.GetLength(1) - 1
m3(i, k) += m1(i, j) * m2(j, k)
Next k
Next j
Next i
Return m3
End Function
End Class
view raw Matrix.vb hosted with ❤ by GitHub