void SetDistanceFunction()
        {
            switch (_distance)
            {
            case NearestNeighborsDistance.cosine:
                _distFunc = (VBuffer <float> v1, VBuffer <float> v2) => { return(VectorDistanceHelper.Cosine(v1, v2)); };
                break;

            case NearestNeighborsDistance.L1:
                _distFunc = (VBuffer <float> v1, VBuffer <float> v2) => { return(VectorDistanceHelper.L1(v1, v2)); };
                break;

            case NearestNeighborsDistance.L2:
                _distFunc = (VBuffer <float> v1, VBuffer <float> v2) => { return(VectorDistanceHelper.L2(v1, v2)); };
                break;

            default:
                throw Contracts.Except("No associated distance for {0}", _distance);
            }
        }
Example #2
0
 public float DistanceTo(IPointIdFloat other)
 {
     return(VectorDistanceHelper.L2Norm(coordinates, other.coordinates));
 }