-
Notifications
You must be signed in to change notification settings - Fork 0
/
FunRevisado.vb
66 lines (59 loc) · 2 KB
/
FunRevisado.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Module FunRevisado
'Multicplica dos matrices una de axb y bxc
Public Function Multiplicar(ByVal Mat1 As Double(,), ByVal Mat2 As Double(,), ByVal a As Integer, ByVal b As Integer, ByVal c As Integer) As Double(,)
Dim MatRespuesta As Double(,)
ReDim MatRespuesta(a + 3, c + 3)
Dim i, j, k As Integer
Dim pp As Double = 0
For i = 1 To a
For j = 1 To c
pp = 0
For k = 1 To b
pp += Mat1(i, k) * Mat2(k, j)
Next
MatRespuesta(i, j) = pp
Next
Next
Return MatRespuesta
End Function
'Resta dos matrices renglon, es de uso especifico
Public Function Restar(ByVal Mat1 As Double(,), ByVal Mat2 As Double(,), ByVal ini As Integer, ByVal fin As Integer) As Double(,)
Dim i As Integer
Dim MatRespuesta As Double(,)
ReDim MatRespuesta(1 + 3, fin + 3)
For i = ini To fin
MatRespuesta(1, i) = Mat1(1, i) - Mat2(1, i)
Next
Return MatRespuesta
End Function
'Copiar una matriz
Public Function Copiar(ByVal MatTemp As Double(,)) As Double(,)
Return MatTemp
End Function
Public Sub HacerIdentidad(ByRef MatTemp As Double(,), ByVal tam As Integer)
Dim i, j As Integer
For i = 1 To tam
For j = 1 To tam
If i = j Then
MatTemp(i, j) = 1
Else
MatTemp(i, j) = 0
End If
Next
Next
End Sub
Public Function StrM(ByVal k1 As Double, ByVal k2 As Double) As String
'Para que en el dgv se vea bonito el renglon Z
Dim str As String = ""
If k1 <> 0 Then
str = k1 & "M"
If k2 < 0 Then
str &= " " & k2
ElseIf k2 > 0 Then
str &= " + " & k2
End If
Else : str = k2
End If
Return str
End Function
End Module