예제 #1
0
        public void NBestHeap(Array <float> mb, float[] bestd, int[] bestw)
        {
            var scores  = NN.Dot(Vectors, mb);
            var mapping = Enumerable.Range(0, Text.Length).ToArray();

            Sorting.Heapsort(scores.Values, mapping, bestd, bestw);
        }
예제 #2
0
        public void NBestQs(Array <float> mb, float[] bestd, int[] bestw, float initPivot = 0, int threshold = 3)
        {
            var scores  = NN.Dot(Vectors, mb);
            var mapping = Enumerable.Range(0, Text.Length).ToArray();
            int k       = Sorting.Quickselect(scores.Values, mapping, bestd.Length, initPivot, threshold);

            for (int i = 0; i < bestd.Length; i++)
            {
                bestd[i] = float.NegativeInfinity;
            }
            for (int c = k; c < Text.Length; c++)
            {
                for (int a = 0; a < bestd.Length; a++)
                {
                    var dist = scores.Values[c];
                    if (dist > bestd[a])
                    {
                        for (int d = bestd.Length - 1; d > a; d--)
                        {
                            bestd[d] = bestd[d - 1];
                            bestw[d] = bestw[d - 1];
                        }
                        bestd[a] = dist;
                        bestw[a] = mapping[c];
                        break;
                    }
                }
            }
        }
예제 #3
0
        public void NBestHeapParallel(Array <float> mb, float[][] bestd, int[][] bestw)
        {
            Debug.Assert(mb.Shape[1] == bestd.Length && mb.Shape[1] == bestw.Length);
            var scores = NN.Dot(Vectors, mb);

            Sorting.HeapsortParallel(scores, bestd, bestw);
        }
예제 #4
0
        public void NBestClassic(Array <float> mb, float[][] bestd, int[][] bestw)
        {
            Debug.Assert(mb.Shape[1] == bestd.Length && mb.Shape[1] == bestw.Length);
            var scores = NN.Dot(Vectors, mb);

            Sorting.Sort(scores, bestd, bestw);
        }
예제 #5
0
 private double DotProduct(Array <float> vec1, Array <float> vec2)
 {
     return((double)NN.Dot(vec1, vec2));
 }
예제 #6
0
 public Array <float> NumNetDotFlat() => NN.Dot(numnet_flat_1, numnet_flat_2);
예제 #7
0
        public void NBestHeap(Array <float> mb, float[] bestd, int[] bestw)
        {
            var scores = NN.Dot(Vectors, mb);

            Sorting.Heapsort(scores.Values, bestd, bestw);
        }