Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

TXT / ma tran

.txt
Скачиваний:
3
Добавлен:
07.01.2014
Размер:
5.32 Кб
Скачать

Public Sub MovMatr(Row As Integer, Col As Integer, Matr() As Single, ResMatr() As Single)
Dim i As Integer, j As Integer
For i = 1 To Row Step 1
For j = 1 To Col Step 1
ResMatr(i, j) = Matr(i, j)
Next j
Next i
End Sub




Public Sub MovVect(Row As Integer, Vect() As Single, ResVect() As Single)
Dim i As Integer
For i = 1 To Row Step 1
ResVect(i) = Vect(i)
Next i
End Sub




Public Sub AddMatr(Row As Integer, Col As Integer, LeftMatr() As Single, _
RightMatr() As Single, ResMatr() As Single)
Dim i As Integer, j As intreger
For i = 1 To Row Step 1
For j = 1 To Col Step 1
ReMatr(i, j) = LeftMatr(i, j) + RightMatr(i, j)
Next j
Next i
End Sub




Public Sub MultMatr(LeftRow As Integer, Col_Row As Integer, RightCol As Integer, _
LeftMatr() As Single, RightMatr() As Single, ResMatr() As Single)
Dim s As Single, i As Integer, j As Integer, l As Integer
For i = 1 To LeftRow Step 1
For j = 1 To RightCol Step 1
s = 0
For l = 1 To Col_Row Step 1
s = s + LeftMatr(i, l) * RightMatr(l, j)
Next l
ResMatr(i, j) = s
Next j
Next i
End Sub






Public Sub SubMatr(Row As Integer, Col As Integer, LeftMatr() As Single, _
RightMatr() As Single, ResMatr() As Single)
Dim i As Integer, j As Integer, l As Integer
For i = 1 To Row Step 1
For j = 1 To Col Step 1
ResMatr(i, j) = LeftMatr(i, j) - RightMatr(i, j)
Next j
Next i
End Sub



Public Sub AddVect(Row As Integer, LeftVect() As Single, RightVect() As Single, ResVect() As Single)
Dim i As Integer
For i = 1 To Row Step 1
ResVect(i) = LeftVect(i) + RightVect(i)
Next i
End Sub



Public Sub SubVect(Row As Integer, LeftVect() As Single, RightVect() As Single, ResVect() As Single)
Dim i As Integer
For i = 1 To Row Step 1
ResVect(i) = LeftVect(i) - RightVect(i)
Next i
End Sub



Public Sub TranspMatr(Row As Integer, Col As Integer, Matr() As Single, ResMatr() As Single)
Dim i As Integer, j As Integer
For i = 1 To Row Step 1
For j = 1 To Col Step 1
ResMatr(j, i) = Matr(i, j)
Next j
Next i
End Sub



Public Sub TranspVect(Row As Integer, Vect() As Single, ResVect() As Single)
Dim i As Integer
For i = 1 To Row Step 1
ResVect(i) = Vect(i)
Next i
End Sub






Public Sub MultMatrVect(Row As Integer, ColRow As Integer, Matr() As Single, _
Vect() As Single, ResVect() As Single)
Dim i As Integer, j As Integer, s As Single
For i = 1 To Row Step 1
s = 0
For j = 1 To ColRow Step 1
s = s + Matr(i, j) * Vect(j)
Next j
ResVect(i) = s
Next i
End Sub



Public Sub MultVectMatr(Row As Integer, Col As Integer, LeftVect() As Single, _
RightMatr() As Single, ResVect() As Single)
Dim s As Single, i As Integer, j As Integer, l As Integer
For j = 1 To Col Step 1
s = 0
For i = 1 To Row Step 1
s = s + LeftVect(i) * RightMatr(i, j)
Next i
ResVect(j) = s
Next j
End Sub




Public Sub MultVectVect(Row As Integer, Col As Integer, LeftVect() As Single, _
RightVect() As Single, ResMatr() As Single)
Dim i As Integer, j As Integer, l As Integer
For i = 1 To Row Step 1
For j = 1 To Col Step 1
ResMatr(i, j) = LeftVect(i) * RightVect(j)
Next j
Next i

End Sub





Public Function ScalMult(Row As Integer, LeftVect() As Single, RightVect() As Single) As Single
Dim s As Single, i As Integer
s = 0
For i = 1 To Row Step 1
s = s + LeftVect(i) * RightVect(i)
Next i
ScalMult = s
End Function




Public Function NormMatr(Row As Integer, Col As Integer, Matr() As Single) As Single
Dim norma As Single, i As Integer, j As Integer
norma = 0
For i = 1 To Row Step 1
For j = 1 To Col Step 1
norma = norma + Matr(i, j) * Matr(i, j)
Next j
Next i
NormMatr = Sqr(norma)
End Function



Public Function NormaVect(Row As Integer, Vect() As Single) As Single
Dim norma As Single, i As Integer
norma = 0
For i = 1 To Row Step 1
norma = norma + Vect(i) * Vect(i)
Next i
NormaVect = Sqr(norma)
End Function



Public Function Sled(Row As Integer, Matr() As Single) As Single
Dim s As Single, i As Integer
s = 1
For i = 1 To Row Step 1
s = s * Matr(i, i)
Next i
Sled = s
End Function




Public Sub OutputMatrix(sh As String, UpRow As Integer, leftCol As Integer, _
Row As Integer, Col As Integer, Matr() As Single)
For i = 1 To Row Step 1
For j = 1 To Col Step 1
Worksheets(sh).Cells(UpRow - 1 + i, leftCol - 1 + j) = Matr(i, j)
Next j
Next i
End Sub




Public Sub OutputVector(sh As String, UpRow As Integer, leftCol As Integer, _
Row As Integer, Vect() As Single)
For i = 1 To Row Step 1
Worksheets(sh).Cells(UpRow - 1 + i, leftCol) = Vect(i)
Next i
End Sub




Public Sub InputMatrix(sh As String, UpRow As Integer, leftCol As Integer, _
Row As Integer, Col As Integer, Matr() As Single)
For i = 1 To Row Step 1
For j = 1 To Col Step 1
Matr(i, j) = Worksheets(sh).Cells(UpRow - 1 + i, leftCol - 1 + j)
Next j
Next i
End Sub




Public Sub InputVector(sh As String, UpRow As Integer, leftCol As Integer, _
Row As Integer, Vect() As Single)
For i = 1 To Row Step 1
Vect(i) = Worksheets(sh).Cells(UpRow - 1 + i, leftCol)
Next i
End Sub



Соседние файлы в папке TXT