Beispiel #1
0
 protected virtual void ComputeDistRow(DynamicSequentialOrdered idxseq, Random rand, HashSet<int> already_pivot, List<EPivot> pivs, List<ItemPair> _items)
 {
     _items.Clear ();
     int n = idxseq.DB.Count;
     int piv;
     do {
         piv = rand.Next(0, n);
     } while (already_pivot.Contains(piv));
     already_pivot.Add (piv);
     var stats = new DynamicSequential.Stats ();
     idxseq.ComputeDistances (idxseq.DB [piv], _items, out stats);
     int pivID = pivs.Count;
     pivs.Add(new EPivot(piv, stats.stddev, stats.mean, stats.min, stats.max, 0, 0));
     if (this.Items == null) {
         this.Items = new ItemPair[n];
         for (int objID = 0; objID < n; ++objID) {
             this.Items[objID] = new ItemPair(0, _items[objID].Dist);
         }
     } else {
         for (int objID = 0; objID < n; ++objID) {
             var new_piv = pivs[pivID];
             var new_dist = _items[objID].Dist;
             var old_piv = pivs[ this.Items[objID].ObjID ];
             var old_dist = this.Items[objID].Dist;
             if (Math.Abs(old_dist - old_piv.mean) < Math.Abs (new_dist - new_piv.mean)) {
                 this.Items[objID] = new ItemPair(pivID, _items[objID].Dist);
             }
         }
     }
 }
Beispiel #2
0
 protected virtual DynamicSequential.Stats ComputeDistRow(int piv, DynamicSequentialOrdered idxseq, Random rand, List<EPivot> pivs, List<ItemPair> _items)
 {
     _items.Clear ();
     int n = idxseq.DB.Count;
     var stats = new DynamicSequential.Stats ();
     idxseq.ComputeDistances (idxseq.DB [piv], _items, out stats);
     int pivID = pivs.Count;
     pivs.Add(new EPivot(piv, stats.stddev, stats.mean, stats.min, stats.max, 0, 0));
     if (this.Items == null) {
         this.Items = new ItemPair[n];
         for (int objID = 0; objID < n; ++objID) {
             this.Items[objID] = new ItemPair(0, _items[objID].Dist);
         }
     } else {
         for (int objID = 0; objID < n; ++objID) {
             var new_piv = pivs[pivID];
             var new_dist = _items[objID].Dist;
             var old_piv = pivs[ this.Items[objID].ObjID ];
             var old_dist = this.Items[objID].Dist;
             if (Math.Abs(old_dist - old_piv.mean) < Math.Abs (new_dist - new_piv.mean)) {
                 this.Items[objID] = new ItemPair(pivID, _items[objID].Dist);
             }
         }
     }
     return stats;
 }