## Verifying Matrix Multiplication results from CUBLAS, using NumPy

``````

In [1]:

import numpy
import numpy as np

``````
``````

In [2]:

m=6
n=4
k=5

``````
``````

In [3]:

A = np.array(range(11,41)).reshape((k,m))
A = A.T
B = np.array(range(11,31)).reshape((n,k))
B = B.T
C = np.array(range(11,35)).reshape((n,m))
C = C.T

``````
``````

In [4]:

print(A); print(B); print(C)

``````
``````

[[11 17 23 29 35]
[12 18 24 30 36]
[13 19 25 31 37]
[14 20 26 32 38]
[15 21 27 33 39]
[16 22 28 34 40]]
[[11 16 21 26]
[12 17 22 27]
[13 18 23 28]
[14 19 24 29]
[15 20 25 30]]
[[11 17 23 29]
[12 18 24 30]
[13 19 25 31]
[14 20 26 32]
[15 21 27 33]
[16 22 28 34]]

``````
``````

In [5]:

np.dot(A,B)+C

``````
``````

Out[5]:

array([[1566, 2147, 2728, 3309],
[1632, 2238, 2844, 3450],
[1698, 2329, 2960, 3591],
[1764, 2420, 3076, 3732],
[1830, 2511, 3192, 3873],
[1896, 2602, 3308, 4014]])

``````
``````

In [6]:

np.dot(A,B)

``````
``````

Out[6]:

array([[1555, 2130, 2705, 3280],
[1620, 2220, 2820, 3420],
[1685, 2310, 2935, 3560],
[1750, 2400, 3050, 3700],
[1815, 2490, 3165, 3840],
[1880, 2580, 3280, 3980]])

``````
``````

In [ ]:

``````