当前位置: 首页>>代码示例>>Java>>正文


Java ArrayUtils.parallelQuicksortDescending方法代码示例

本文整理汇总了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);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:33,代码来源:GeneralisedEigenvalueProblem.java

示例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");
}
 
开发者ID:jonhare,项目名称:COMP3005,代码行数:29,代码来源:KNNDemo.java

示例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;
}
 
开发者ID:jonhare,项目名称:COMP3204,代码行数:35,代码来源:TomatoKNNClassifierDemo.java

示例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");
}
 
开发者ID:jonhare,项目名称:COMP3204,代码行数:29,代码来源:KNNDemo.java


注:本文中的org.openimaj.util.array.ArrayUtils.parallelQuicksortDescending方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。