Outer

This method computes an outer operation on <op>. It computes <op>(a2, b2) where a2 is 'a' with b.ndim 1's post-pended to it's shape and b2 is 'b' with a.ndim 1's pre-pended to its shape (broadcasting takes care of this automatically in the code below). The return shape has a.ndim + b.ndim dimensions. Equivalent Python code is

Among many other uses, arithmetic tables can be conveniently built using outer:

>>> multiply

.outer( [1,7,9,

12]

arange(5

12) )

array([[ 5,

6

7, 8

,

9, 10,

11] ,

[ 35, 42,

49,

56, 63,

70

77] ,

[ 45, 54,

63 ,

72, 81,

90

99] ,

[ 60, 72,

84,

96, 108,

120

132]])

0 0

Post a comment