-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathnumpy_inner_outer.py
58 lines (37 loc) · 948 Bytes
/
numpy_inner_outer.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
"""
Problem Statement
inner
The inner tool returns the inner product of two arrays.
import numpy
A = numpy.array([0, 1])
B = numpy.array([3, 4])
print numpy.inner(A, B) #Output : 4
outer
The outer tool returns the outer product of two arrays.
import numpy
A = numpy.array([0, 1])
B = numpy.array([3, 4])
print numpy.outer(A, B) #Output : [[0 0]
# [3 4]]
Task
You are given two arrays: A and B.
Your task is to compute their inner and outer product.
Input Format
The first line contains the space separated elements of array A.
The second line contains the space separated elements of array B.
Output Format
First, print the inner product.
Second, print the outer product.
Sample Input
0 1
2 3
Sample Output
3
[[0 0]
[2 3]]
"""
import numpy
a,b = [map(int,raw_input().split()) for _ in xrange(2)]
A,B = numpy.array(a),numpy.array(b)
print numpy.inner(A,B)
print numpy.outer(A,B)