/* This file was generated by scramble.py. */
#include "algo2/wed.h"
#include "scramble.h"
V WED(Vector *v, Vector *v2, V *weights)
{
    /* 
     * Weighted Euclidean Distance. */
    V sdistance = 0;
    int n = v->count;
    for (int i = 0; i < n; i++)
    {
        V x = *(V *)vector_get(v, i);
        V xi = *(V *)vector_get(v2, i);
        V d = (x - xi) * (x - xi);
        if (weights)
        {
            d *= weights[i];
        }
        sdistance += d;
    }
    sdistance /= n;
    /* Force into 0..1 */
    sdistance /= 1 + sdistance;
    return sdistance;
}
/* This file was generated by scramble.py. */
