MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / VPTree

Method VPTree

JSAT/src/jsat/linear/vectorcollection/VPTree.java:69–109  ·  view source on GitHub ↗
(List<V> list, DistanceMetric dm, VPSelection vpSelection, Random rand, int sampleSize, int searchIterations, ExecutorService threadpool)

Source from the content-addressed store, hash-verified

67 }
68
69 public VPTree(List<V> list, DistanceMetric dm, VPSelection vpSelection, Random rand, int sampleSize, int searchIterations, ExecutorService threadpool)
70 {
71 this.dm = dm;
72 if(!dm.isSubadditive())
73 throw new RuntimeException("VPTree only supports metrics that support the triangle inequality");
74 this.rand = rand;
75 this.sampleSize = sampleSize;
76 this.searchIterations = searchIterations;
77 this.size = list.size();
78 this.vpSelection = vpSelection;
79 this.allVecs = list;
80 if(threadpool == null || threadpool instanceof FakeExecutor)
81 distCache = dm.getAccelerationCache(allVecs);
82 else
83 distCache = dm.getAccelerationCache(allVecs, threadpool);
84 //Use simple list so both halves can be modified simultaniously
85 List<Pair<Double, Integer>> tmpList = new SimpleList<Pair<Double, Integer>>(list.size());
86 for(int i = 0; i < allVecs.size(); i++)
87 tmpList.add(new Pair<Double, Integer>(-1.0, i));
88 if(threadpool == null)
89 this.root = makeVPTree(tmpList);
90 else
91 {
92 ModifiableCountDownLatch mcdl = new ModifiableCountDownLatch(1);
93 this.root = makeVPTree(tmpList, threadpool, mcdl);
94 mcdl.countDown();
95 try
96 {
97 mcdl.await();
98 }
99 catch (InterruptedException ex)
100 {
101 Logger.getLogger(VPTree.class.getName()).log(Level.SEVERE, null, ex);
102 System.err.println("Falling back to single threaded VPTree constructor");
103 tmpList.clear();
104 for(int i = 0; i < list.size(); i++)
105 tmpList.add(new Pair<Double, Integer>(-1.0, i));
106 this.root = makeVPTree(tmpList);
107 }
108 }
109 }
110
111 public VPTree(List<V> list, DistanceMetric dm, VPSelection vpSelection, Random rand, int sampleSize, int searchIterations)
112 {

Callers

nothing calls this directly

Calls 14

addMethod · 0.95
makeVPTreeMethod · 0.95
countDownMethod · 0.95
awaitMethod · 0.95
getRandomMethod · 0.95
cloneChangeContextMethod · 0.95
logMethod · 0.80
isSubadditiveMethod · 0.65
sizeMethod · 0.65
getAccelerationCacheMethod · 0.65
getNameMethod · 0.65
supportsAccelerationMethod · 0.65

Tested by

no test coverage detected