-
Notifications
You must be signed in to change notification settings - Fork 0
/
testRazs.py
33 lines (33 loc) · 1.14 KB
/
testRazs.py
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
from matrixMultiplyRazs import matrixMultiplyRaz, sumLog
from unittest import TestCase, main
from random import randint
class testProduct(TestCase):
def testSumLog(self):
k = 1
trueSig = True
while k <= 30:
A = [randint(0,100) for j in range(k)]
B = [randint(0,100) for j in range(k)]
C = [A[j]*B[j] for j in range(k)]
C1 = sumLog(A,B)
C2 = sum(C)
trueSig = trueSig and (C1==C2)
k = k + 1
self.assertTrue(trueSig)
def testProduct(self):
k = 1
trueSig = True
while k <= 30:
A = [[randint(0,100) for j in range(k)] for i in range(k)]
B = [[randint(0,100) for j in range(k)] for i in range(k)]
C1 = [[0 for j in range(k)] for i in range(k)]
for m in range(k):
for n in range(k):
for p in range(k):
C1[m][n] = C1[m][n] + A[m][p] * B[p][n]
C2 = matrixMultiplyRaz(A,B)
trueSig = trueSig and (C1==C2)
k = k + 1
self.assertTrue(trueSig)
if __name__ == '__main__':
main()