-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathnumpy_dot_cross.py
59 lines (38 loc) · 1022 Bytes
/
numpy_dot_cross.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""
Problem Statement
dot
The dot tool returns the dot product of two arrays.
import numpy
A = numpy.array([ 1, 2 ])
B = numpy.array([ 3, 4 ])
print numpy.dot(A, B) #Output : 11
cross
The cross tool returns the cross product of two arrays.
import numpy
A = numpy.array([ 1, 2 ])
B = numpy.array([ 3, 4 ])
print numpy.cross(A, B) #Output : -2
Task
You are given two arrays A and B. Both have dimensions of NXN.
Your task is to compute their matrix product.
Input Format
The first line contains the integer N.
The next N lines contains N space separated integers of array A.
The following N lines contains N space separated integers of array B.
Output Format
Print the matrix multiplication of A and B.
Sample Input
2
1 2
3 4
1 2
3 4
Sample Output
[[ 7 10]
[15 22]]
"""
import numpy
k = map(int,raw_input().split())
l,m = [ map(int,raw_input().split()) for _ in xrange(k[0]) ],[map(int,raw_input().split()) for _ in xrange(k[0]) ]
a,b = numpy.array(l),numpy.array(m)
print numpy.dot(a,b)