distUnitk {WaveSampling}R Documentation

Squared Euclidean distances of the unit k.

Description

Calculate the squared Euclidean distance from unit kk to the other units.

Usage

distUnitk(X, k, tore, toreBound)

Arguments

X

matrix representing the spatial coordinates.

k

the unit index to be used.

tore

an optional logical value, if we are considering the distance on a tore. See Details.

toreBound

an optional numeric value that specify the length of the tore.

Details

Let xk,xl\mathbf{x}_k,\mathbf{x}_l be the spatial coordinates of the unit k,lUk,l \in U. The classical euclidean distance is given by

d2(k,l)=(xkxl)(xkxl).d^2(k,l) = (\mathbf{x}_k - \mathbf{x}_l)^\top (\mathbf{x}_k - \mathbf{x}_l).

When the points are distributed on a N1×N2N_1 \times N_2 regular grid of R2R^2. It is possible to consider the units like they were placed on a tore. It can be illustrated by Pac-Man passing through the wall to get away from ghosts. Specifically, we could consider two units on the same column (resp. row) that are on the opposite have a small distance,

dT2(k,l)=min((xk1xl1)2,(xk1+N1xl1)2,(xk1N1xl1)2)+ d^2_T(k,l) = min( (x_{k_1} - x_{l_1})^2, (x_{k_1} + N_1 - x_{l_1})^2, (x_{k_1} - N_1 - x_{l_1})^2) +

min((xk2xl2)2,(xk2+N2xl2)2,(xk2N2xl2)2). min( (x_{k_2} - x_{l_2})^2, (x_{k_2} + N_2 - x_{l_2})^2, (x_{k_2} - N_2 - x_{l_2})^2).

The option toreBound specify the length of the tore in the case of N1=N2=NN_1 = N_2 = N. It is omitted if the tore option is equal to FALSE.

Value

a vector of length NN that contains the distances from the unit kk to all other units.

Author(s)

Raphaël Jauslin raphael.jauslin@unine.ch

See Also

wpik, wave and dist.

Examples

  N <- 5
  x <- seq(1,N,1)
  X <- as.matrix(expand.grid(x,x))
  distUnitk(X,k = 2,tore = TRUE,toreBound = 5)
  distUnitk(X,k = 2,tore = FALSE,toreBound = -1)

[Package WaveSampling version 0.1.3 Index]