Spark method for subtracting 2 vectors

Viewed 27

I am using scala spark. I have a dataframe that 2 column each containing a Vector with the same cardinality/size. I want to find the distance between each element of the 2 Vectors and put the results in a vector in another column of the dataframe.

Example: [1, 3, 5, -2] - [-2, 5, 0, 1] = [3, 2, 5, 3]

I found sqdist method that can get me the sum of the square distances between 2 Vectors but how do I get the individual distances of each elements in the vector.

0 Answers
Related