Let me explain the situation, first:
I have a vector field, where each element has a:
1) 2-D co-ordinate location (x,y)
2) 2-D vector u,v (where u and v represents the displacements in x and y directions respectively)
I am trying to implement the following equation over this vector field:
V' is the new vector field after applying the equation to the input vector field V. Therefore, is the updated (u,v) vector value for the element "i". Also, "j" represents the set of all elements in the vector field, except "i" . Hence, is the (u,v) vector for element "j". Finally, and represent the 2-D co-ordinate location (x,y) for elements i and j respectively.
I have done the following implementation (say, for 100 elements). But, it takes a lot of time to execute when the number of elements increases.
Can you help me to vectorize it, if possible?
sum_temp = 0;
term_2 = exp(-1*(pdist2(xyuv(i,1:2),xyuv(j,1:2))));
term_3 = exp(-1*abs(dot(xyuv(j,3:4), (xyuv(i,1:2)-xyuv(j,1:2)))));
sum_temp = sum_temp + xyuv(j,3:4)*term_2*term_3;
new_V(i,:) = sum_temp;