public void NBestVPTree(Array <float> mb, double[] bestd, int[] bestw) { if (_vpTree == null) { _vpTree = new VPTree <Array <float> >(ArrayVectors(), MinusDotProduct); } _vpTree.Search(mb / NN.Norm(mb), bestw, bestd); }
public static void Normalize(Array <float> v) { var norm = NN.Norm(v); if (norm != 0) { v.Div(norm, result: v); } }
private Array <float>[] ArrayVectors() { var vectors = new Array <float> [Text.Length]; for (int i = 0; i < vectors.Length; i++) { vectors[i] = this[Text[i]] / NN.Norm(this[Text[i]]); } return(vectors); }
public static Array <Real> Normalize(this Array <Real> a, Array <Real> result = null) { return(a.Scale(1 / NN.Norm(a), result: result)); }