diff options
author | Julian T <julian@jtle.dk> | 2020-05-16 16:52:12 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2020-05-16 16:52:12 +0200 |
commit | 284afc630b3d0dd6c0079c6d3e83a73d6d1193e0 (patch) | |
tree | 3197f3d38587e53b1e4413813bc41e863ef81413 /sem4/hpp/m9/opgave3.py | |
parent | 56f60d3409c035e12b1d7e21c14ff4f8ab43ecf9 (diff) |
Added hpp assignments
Diffstat (limited to 'sem4/hpp/m9/opgave3.py')
-rw-r--r-- | sem4/hpp/m9/opgave3.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sem4/hpp/m9/opgave3.py b/sem4/hpp/m9/opgave3.py new file mode 100644 index 0000000..15505eb --- /dev/null +++ b/sem4/hpp/m9/opgave3.py @@ -0,0 +1,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") |