Accord.Math.Distance.SquareEuclidean(Sparse<double> x, Sparse<double> y) iterates through the indices of x and y, referencing them by index (i, j).
Doesn't this mean that the indices of x and y need to be of equal length?
In this case what's the point of using Sparse<double>?
int i = 0, j = 0;
while (i < x.Indices.Length && j < y.Indices.Length)
{
int posx = x.Indices[i];
int posy = y.Indices[j];
if (posx == posy)
{
double d = x.Values[i] - y.Values[j];
sum += d * d;
i++;
j++;
}
else if (posx < posy)
{
double d = x.Values[j];
sum += d * d;
i++;
}
else if (posx > posy)
{
double d = y.Values[j];
sum += d * d;
j++;
}
}
Thanks!