aboutsummaryrefslogtreecommitdiff
path: root/sem4/hpp/m9/opgave3.py
blob: 15505eb07d2e977227c55279eea5fa743f2f92e4 (plain)
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
import numpy as np

def matrixmult(a, b):
    res = np.empty((a.shape[0], b.shape[1]))
    for ic, c in enumerate(b.T):
        for ir, r in enumerate(a):
            res[ir][ic] = np.dot(c, r)

    return res

a = np.random.random((100, 300))
b = np.random.random((300, 100))

print("a")
print(a)
print("b")
print(b)

custom = matrixmult(a, b)

ref = a @ b

print("custom")
print(custom)
print("ref")
print(ref)

if np.array_equal(custom, ref):
    print("Yay they are the same, well done")
else:
    print("Not the same, bummer")