I want to vectorize the following function. The arguments are numpy arrays.
def euclidean_distance(dl, dr):
return math.sqrt(((dl - dr) ** 2).sum())
I do the following
v_u = numpy.vectorize(euclidean_distance)
and I am doing the following call
v_u(numpy.array([[10, 20, 30], [4, 5, 6]]), numpy.array([1, 2, 3]))
What I want is that I get back an array which contains the euclidean distance of [1, 2, 3] with [10, 20, 30], [4, 5, 6].
I think I am missing something obvious.
EDIT:
The following is the error I get
AttributeError: 'int' object has no attribute 'sum'
which is obvious that dl and dr are passed as single elements but not as arrays...
So I was wondering if somebody could correct it so that it operated on arrays.
Thanks a lot
[1,2,3],[10,20,30],[4,5,6], they are 3D coordinates? So you want the distance between[1,2,3]and every point in the other array?