void split_points(final byte [][] pnts, IntArrayView inds) { IntFloatPair spl = choose_split(pnts, inds); ((InternalNodeData)node_data).disc_dim = spl.first; ((InternalNodeData)node_data).disc = spl.second; int N = inds.size(); int l = 0; int r = N; while (l!=r) { if (pnts[inds.getFast(l)][((InternalNodeData)node_data).disc_dim] < ((InternalNodeData)node_data).disc) l++; else { r--; int t = inds.getFast(l); inds.setFast(l, inds.getFast(r)); inds.setFast(r, t); } } // If either partition is empty -> vectors identical! if (l==0 || l==N) { l = N/2; } // The vectors are identical, so keep nlogn performance. left = new ByteKDTreeNode(pnts, inds.subView(0, l), rng); ((InternalNodeData)node_data).right = new ByteKDTreeNode(pnts, inds.subView(l, N), rng); }
/** * Construct a ByteKDTreeEnsemble with the provided data and * number of trees. * @param pnts the data array * @param ntrees the number of KDTrees in the ensemble * @param seed the seed for the random number generator used in * tree construction */ public ByteKDTreeEnsemble(final byte [][] pnts, int ntrees, int seed) { final int N = pnts.length; this.pnts = pnts; this.rng = new Uniform(new MersenneTwister(seed)); // Create inds. IntArrayView inds = new IntArrayView(N); for (int n=0; n<N; ++n) inds.setFast(n, n); // Create trees. trees = new ByteKDTreeNode[ntrees]; for (int t=0; t<ntrees; ++t) { trees[t] = new ByteKDTreeNode(pnts, inds,rng); } }
/** * Construct a ByteKDTreeEnsemble with the provided data and * number of trees. * @param pnts the data array * @param ntrees the number of KDTrees in the ensemble * @param seed the seed for the random number generator used in * tree construction */ public ByteKDTreeEnsemble(final byte [][] pnts, int ntrees, int seed) { final int N = pnts.length; this.pnts = pnts; this.rng = new Uniform(new MersenneTwister(seed)); // Create inds. IntArrayView inds = new IntArrayView(N); for (int n=0; n<N; ++n) inds.setFast(n, n); // Create trees. trees = new ByteKDTreeNode[ntrees]; for (int t=0; t<ntrees; ++t) { trees[t] = new ByteKDTreeNode(pnts, inds,rng); } }
void split_points(final byte [][] pnts, IntArrayView inds) { IntFloatPair spl = choose_split(pnts, inds); ((InternalNodeData)node_data).disc_dim = spl.first; ((InternalNodeData)node_data).disc = spl.second; int N = inds.size(); int l = 0; int r = N; while (l!=r) { if (pnts[inds.getFast(l)][((InternalNodeData)node_data).disc_dim] < ((InternalNodeData)node_data).disc) l++; else { r--; int t = inds.getFast(l); inds.setFast(l, inds.getFast(r)); inds.setFast(r, t); } } // If either partition is empty -> vectors identical! if (l==0 || l==N) { l = N/2; } // The vectors are identical, so keep nlogn performance. left = new ByteKDTreeNode(pnts, inds.subView(0, l), rng); ((InternalNodeData)node_data).right = new ByteKDTreeNode(pnts, inds.subView(l, N), rng); }