Reputation: 6632
I have a MATLAB code which I try to convert to C, and it works all fine, but I'm stuck at dist
function. It says that it calculates the Euclidean distance weight function. Calculating the normal Euclidean distance function is pretty easy, but I don't exactly get what the weight means here. In the code that I want to convert there is 1x1000, or to say in another words just a row array with complex values (meaning x + yi). Then it does something like this:
if ((dist(sest(i), -1)) < (dist(sest(i), 1)))
As I said sest
is the 1x1000 matrix of complex values, so it takes each value in a for
loop and puts it into the dist
function with -1 or 1, and the output of dist
function in my case is again a complex number. Any idea what's going on behind the scene? What -1 and 1 is doing there? How is the Euclidean weight function calculated here?
Upvotes: 0
Views: 310
Reputation: 1332
Here the
((dist(sest(i), -1))
is just the equivalent of
abs(sest(i) + 1)
and
for real numbers. ((dist(sest(i), 1))
is the equivalent of
abs(1-sest(i))
for real numbers.
for complex numbers it seems to be that
((dist(sest(i), -1))
is the equivalent of
conj(abs(real(sest(i)) + 1)+ imag(sest(i))*j)
and
((dist(sest(i), 1))
is the equivalent of
abs(1 -real(sest(i))) + imag(sest(i)*j)
Upvotes: 1