Attribute VB_Name = "Module2" '=================================== 'Utility functions for project Pnnes 'Release 1.1: Added Sub mmulvt. '=================================== DefDbl A-H, O-Z DefInt I-N Public nfetot As Integer Function DotProduct(n, a(), b()) Sum = zero For i = 1 To n Sum = Sum + a(i) * b(i) Next i DotProduct = Sum End Function Function IMAX(ia, ib) If ia >= ib Then IMAX = ia Else IMAX = ib End If End Function Function IMIN(ia, ib) If ia <= ib Then IMIN = ia Else IMIN = ib End If End Function Sub Line0() Print #1, " *"; For k = 1 To 71 Print #1, " "; Next k Print #1, "*" End Sub Sub Line1() Print #1, " *"; For k = 1 To 71 Print #1, "-"; Next k Print #1, "*" End Sub Sub mmulvt(n, a(), b(), c()) '*********************************************** '* MULTIPLICATION OF THE TRANSPOSE OF A REAL * '* MATRIX BY A VECTOR * '* ------------------------------------------- * '* INPUTS: A MATRIX N*N (HERE A VECTOR) * '* B VECTOR N*1 * '* N INTEGER * '* ------------------------------------------- * '* OUTPUT: C VECTOR N*1 PRODUCT A*B * '*********************************************** For i = 1 To n Sum = zero For k = 1 To n Sum = Sum + a((k - 1) * ISIZE + i) * b(k) Next k c(i) = Sum Next i End Sub Function XMAX(a, b) If a >= b Then XMAX = a Else XMAX = b End If End Function Function XMIN(a, b) If a <= b Then XMIN = a Else XMIN = b End If End Function Sub Msg(text As String) Print #1, " *"; Print #1, text; l = Len(text) For i = 1 To 73 - l - 2 Print #1, " "; Next i Print #1, "*" End Sub Sub mmulv(n, a(), b(), c()) '*********************************************** '* MULTIPLICATION OF A REAL MATRIX BY A VECTOR * '* ------------------------------------------- * '* INPUTS: A MATRIX N*N (HERE A VECTOR) * '* B VECTOR N*1 * '* N INTEGER * '* ------------------------------------------- * '* OUTPUT: C VECTOR N*1 PRODUCT A*B * '*********************************************** For i = 1 To n Sum = zero For k = 1 To n Sum = Sum + a((i - 1) * ISIZE + k) * b(k) Next k c(i) = Sum Next i End Sub 'for debug only Sub PrintVec(n, Name As String, V()) Print #1, Name For i = 1 To n Print #1, " "; V(i); Next i Print #1, "" End Sub