"cross product", but rise to an indicator, not multiply

I have two vectors. I need the function "cross product" -esque, which will take each value from the first vector and raise it to the exponent of each value in the second vector, returning the matrix. Is there something built into numpy that does this? This can be done with loops, but I'm looking for something effective.

For example:

>>> cross_exp([1,2], [3,4]) 
[[1, 1],[8, 16]]
+4
source share
1 answer

It looks like you might need np.power.outer:

>>> np.power.outer([1,2], [3,4])
array([[ 1,  1],
       [ 8, 16]])

ufuncs outer, ( , ).

+6

Source: https://habr.com/ru/post/1607674/


All Articles