本文整理汇总了Java中org.openimaj.util.array.ArrayUtils.parallelQuicksortDescending方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtils.parallelQuicksortDescending方法的具体用法?Java ArrayUtils.parallelQuicksortDescending怎么用?Java ArrayUtils.parallelQuicksortDescending使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openimaj.util.array.ArrayUtils
的用法示例。
在下文中一共展示了ArrayUtils.parallelQuicksortDescending方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: symmetricGeneralisedEigenvectorsSorted
import org.openimaj.util.array.ArrayUtils; //导入方法依赖的package包/类
/**
* Solve the general problem A x = L B x.
* The returned eigenvalues ordered in a decreasing manner.
*
* @param A symmetric matrix A
* @param B symmetric matrix B
* @return The eigenvectors x and eigenvalues L.
*/
public static IndependentPair<Matrix, double[]> symmetricGeneralisedEigenvectorsSorted(Matrix A, Matrix B) {
if ((A.getRowDimension() != A.getColumnDimension()) || (B.getRowDimension() != B.getColumnDimension()))
throw new IllegalArgumentException("Input matrices must be square");
int dim = A.getRowDimension();
DenseMatrix vecs = new DenseMatrix(A.getArray());
DenseVector W = new DenseVector(dim);
sygvd(1, "V", "U", vecs, new DenseMatrix(B.getArray()), W);
Matrix evecs = new Matrix(dim, dim);
final double[][] evecsData = evecs.getArray();
final double[] vecsData = vecs.getData();
final double[] valsData = W.getData();
int [] indices = ArrayUtils.range(0, valsData.length-1);
ArrayUtils.parallelQuicksortDescending(valsData, indices);
for (int r=0; r<dim; r++)
for (int c=0; c<dim; c++)
evecsData[r][c] = vecsData[r + indices[c] * dim];
return new IndependentPair<Matrix, double[]>(evecs, valsData);
}
示例2: doClassify
import org.openimaj.util.array.ArrayUtils; //导入方法依赖的package包/类
private void doClassify(double[] mean) {
if (points.size() > 0) {
final DoubleNearestNeighboursExact nn = new DoubleNearestNeighboursExact(
points.toArray(new double[points.size()][]));
final List<IntDoublePair> neighbours = nn.searchKNN(mean, k);
final int[] counts = new int[CLASSES.length];
for (final IntDoublePair p : neighbours) {
counts[this.classes.get(p.first)]++;
final double[] pt = this.points.get(p.first);
final Point2dImpl pti = projectPoint(pt);
image.drawPoint(pti, RGBColour.MAGENTA, POINT_SIZE);
image.drawShape(new Circle(pti, CIRCLE_SIZE), CIRCLE_THICKNESS, RGBColour.GREEN);
}
imageComp.setImage(bimg = ImageUtilities.createBufferedImageForDisplay(image, bimg));
final int[] indices = ArrayUtils.range(0, counts.length - 1);
ArrayUtils.parallelQuicksortDescending(counts, indices);
if (counts.length == 1 || counts[0] > counts[1]) {
guess.setText((String) this.classType.getItemAt(indices[0]));
return;
}
}
guess.setText("unknown");
}
示例3: doClassify
import org.openimaj.util.array.ArrayUtils; //导入方法依赖的package包/类
private Float[] doClassify(double[] mean) {
if (points.size() > 0) {
final DoubleNearestNeighboursExact nn = new DoubleNearestNeighboursExact(
points.toArray(new double[points.size()][]));
final List<IntDoublePair> neighbours = nn.searchKNN(mean, k);
if (neighbours.get(0).second > 0.05) {
guess.setText("unknown");
return RGBColour.MAGENTA;
}
final int[] counts = new int[CLASSES.length];
for (final IntDoublePair p : neighbours) {
counts[this.classes.get(p.first)]++;
final double[] pt = this.points.get(p.first);
final Point2dImpl pti = projectPoint(pt);
image.drawPoint(pti, RGBColour.MAGENTA, POINT_SIZE);
image.drawShape(new Circle(pti, CIRCLE_SIZE), CIRCLE_THICKNESS, RGBColour.GREEN);
}
imageComp.setImage(bimg = ImageUtilities.createBufferedImageForDisplay(image, bimg));
final int[] indices = ArrayUtils.range(0, counts.length - 1);
ArrayUtils.parallelQuicksortDescending(counts, indices);
if (counts.length == 1 || counts[0] > counts[1]) {
guess.setText(this.classType.getItemAt(indices[0]));
return COLOURS[indices[0]];
}
}
guess.setText("unknown");
return RGBColour.MAGENTA;
}
示例4: doClassify
import org.openimaj.util.array.ArrayUtils; //导入方法依赖的package包/类
private void doClassify(double[] mean) {
if (points.size() > 0) {
final DoubleNearestNeighboursExact nn = new DoubleNearestNeighboursExact(
points.toArray(new double[points.size()][]));
final List<IntDoublePair> neighbours = nn.searchKNN(mean, k);
final int[] counts = new int[CLASSES.length];
for (final IntDoublePair p : neighbours) {
counts[this.classes.get(p.first)]++;
final double[] pt = this.points.get(p.first);
final Point2dImpl pti = projectPoint(pt);
image.drawPoint(pti, RGBColour.MAGENTA, POINT_SIZE);
image.drawShape(new Circle(pti, CIRCLE_SIZE), CIRCLE_THICKNESS, RGBColour.GREEN);
}
imageComp.setImage(bimg = ImageUtilities.createBufferedImageForDisplay(image, bimg));
final int[] indices = ArrayUtils.range(0, counts.length - 1);
ArrayUtils.parallelQuicksortDescending(counts, indices);
if (counts.length == 1 || counts[0] > counts[1]) {
guess.setText(this.classType.getItemAt(indices[0]));
return;
}
}
guess.setText("unknown");
}