I wonder if there are very simple ways to calculate pairwise subtraction for two elements in a multi-dimensional array which is consisted of vectors USING a function in NUMPY or SCIPY library.
Let me introduce an example:
>>> a = (np.arange(9)).reshape((3,3)) # a list of 3 vectors (x, y, z)
>>> a
array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
I want to get the following:
>>>> result
array([[3,3,3],
[6,6,6],
[3,3,3]])
# first element comes from [3,4,5] - [0,1,2]
# second element comes from [6,7,8] - [0,1,2]
# third element comes from [6,7,8] - [3,4,5]
I do not matter about the signs (+/-) on the result which depends on the order of subtraction of two vectors. But, I want to know VERY SIMPLE version of code using pre-defined functions in Scipy or Numpy libraries such as scipy.spatial.distance.pdist.
I do need loop codes to iterate elements-wise for result, instead, I need just one line to get the result.