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


Java CommonOps.scale方法代码示例

本文整理汇总了Java中org.ejml.ops.CommonOps.scale方法的典型用法代码示例。如果您正苦于以下问题:Java CommonOps.scale方法的具体用法?Java CommonOps.scale怎么用?Java CommonOps.scale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ejml.ops.CommonOps的用法示例。


在下文中一共展示了CommonOps.scale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: MatrixFormulation

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
private MatrixFormulation() {
    int numRows = response.length;
    int numCols = predictors.length + ((hasIntercept) ? 1 : 0);
    this.X = createMatrixA(numRows, numCols);
    this.Xt = new DenseMatrix64F(numCols, numRows);
    CommonOps.transpose(X, Xt);
    this.XtXInv = new DenseMatrix64F(numCols, numCols);
    this.b = new DenseMatrix64F(numCols, 1);
    this.y = new DenseMatrix64F(numRows, 1);
    solveSystem(numRows, numCols);
    this.fitted = computeFittedValues();
    this.residuals = computeResiduals();
    this.sigma2 = estimateSigma2(numCols);
    this.covarianceMatrix = new DenseMatrix64F(numCols, numCols);
    CommonOps.scale(sigma2, XtXInv, covarianceMatrix);
}
 
开发者ID:signaflo,项目名称:java-timeseries,代码行数:17,代码来源:MultipleLinearRegressionModel.java

示例2: decompose

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
 * Compute the decomposition given the SVD of E=U*S*V<sup>T</sup>.
 *
 * @param U Orthogonal matrix from SVD.
 * @param S Diagonal matrix containing singular values from SVD.
 * @param V Orthogonal matrix from SVD.
 */
public void decompose( DenseMatrix64F U , DenseMatrix64F S , DenseMatrix64F V ) {
	// this ensures the resulting rotation matrix will have a determinant of +1 and thus be a real rotation matrix
	if( CommonOps.det(U) < 0 ) {
		CommonOps.scale(-1,U);
		CommonOps.scale(-1,S);
	}

	if( CommonOps.det(V) < 0 ) {
		CommonOps.scale(-1,V);
		CommonOps.scale(-1,S);
	}

	// for possible solutions due to ambiguity in the sign of T and rotation
	extractTransform(U, V, S, solutions.get(0), true, true);
	extractTransform(U, V, S, solutions.get(1), true, false);
	extractTransform(U, V, S, solutions.get(2) , false,false);
	extractTransform(U, V, S, solutions.get(3), false, true);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:26,代码来源:DecomposeEssential.java

示例3: extractFundamental_threeview

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
@Test
public void extractFundamental_threeview() {
	DenseMatrix64F found2 = new DenseMatrix64F(3,3);
	DenseMatrix64F found3 = new DenseMatrix64F(3,3);

	TrifocalTensor input = tensor.copy();
	MultiViewOps.extractFundamental(input, found2, found3);

	// make sure the input was not modified
	for( int i = 0; i < 3; i++ )
		assertTrue(MatrixFeatures.isIdentical(tensor.getT(i),input.getT(i),1e-8));

	CommonOps.scale(1.0/CommonOps.elementMaxAbs(found2),found2);
	CommonOps.scale(1.0/CommonOps.elementMaxAbs(found3),found3);

	Point3D_F64 X = new Point3D_F64(0.1,0.05,2);

	// remember the first view is assumed to have a projection matrix of [I|0]
	Point2D_F64 x1 = PerspectiveOps.renderPixel(new Se3_F64(), null, X);
	Point2D_F64 x2 = PerspectiveOps.renderPixel(worldToCam2, K, X);
	Point2D_F64 x3 = PerspectiveOps.renderPixel(worldToCam3, K, X);

	assertEquals(0, MultiViewOps.constraint(found2, x1, x2), 1e-8);
	assertEquals(0, MultiViewOps.constraint(found3, x1, x3), 1e-8);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:26,代码来源:TestMultiViewOps.java

示例4: checkScaleInvariance

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
 * Scale the input and see if that changes the error
 */
@Test
public void checkScaleInvariance() {
	DistanceEpipolarConstraint alg = new DistanceEpipolarConstraint();
	alg.setModel(F);

	p1.x += 0.2;
	p1.y += 0.2;

	double orig = alg.computeDistance(new AssociatedPair(p1,p2));

	// rescale the matrix and see if that changes the results
	CommonOps.scale(5,F);
	alg.setModel(F);

	double after = alg.computeDistance(new AssociatedPair(p1,p2));

	assertEquals(orig,after,1e-8);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:22,代码来源:TestDistanceEpipolarConstraint.java

示例5: times

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
public Matrix times(double value) {
	DenseMatrix64F ret = new DenseMatrix64F(matrix.numRows, matrix.numCols);
	CommonOps.scale(value, matrix, ret);
	Matrix result = new EJMLDenseDoubleMatrix2D(ret);
	MapMatrix<String, Object> a = getMetaData();
	if (a != null) {
		result.setMetaData(a.clone());
	}
	return result;
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:11,代码来源:EJMLDenseDoubleMatrix2D.java

示例6: divide

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
public Matrix divide(double value) {
	DenseMatrix64F ret = new DenseMatrix64F(matrix.numRows, matrix.numCols);
	CommonOps.scale(1.0 / value, matrix, ret);
	Matrix result = new EJMLDenseDoubleMatrix2D(ret);
	MapMatrix<String, Object> a = getMetaData();
	if (a != null) {
		result.setMetaData(a.clone());
	}
	return result;
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:11,代码来源:EJMLDenseDoubleMatrix2D.java

示例7: evaluateAll

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
public void evaluateAll( GeoModelEstimator1<DenseMatrix64F,AssociatedPair> estimator ) {
	scores = new ArrayList<Double>();
	int failed = 0;

	DenseMatrix64F F = new DenseMatrix64F(3,3);

	for( int i = 0; i < 50; i++ ) {

		if( !estimator.process(observations,F) ) {
			failed++;
			continue;
		}

		// normalize the scale of F
		CommonOps.scale(1.0/CommonOps.elementMaxAbs(F),F);

		// score against all observations
		for( AssociatedPair p : observations ) {
			double score = Math.abs(GeometryMath_F64.innerProd(p.p2, F, p.p1));
			if( Double.isNaN(score))
				System.out.println("Score is NaN");
			scores.add(score);
		}
	}

	Collections.sort(scores);

	System.out.printf(" Failures %3d  Score:  50%% = %6.3e  95%% = %6.3e\n", failed, scores.get(scores.size() / 2), scores.get((int) (scores.size() * 0.95)));
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:30,代码来源:BenchmarkStabilityFundamental.java

示例8: adjustHomographSign

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
 * Since the sign of the homography is ambiguous a point is required to make sure the correct
 * one was selected.
 *
 * @param p test point, used to determine the sign of the matrix.
 */
protected void adjustHomographSign( AssociatedPair p , DenseMatrix64F H ) {
	double val = GeometryMath_F64.innerProd(p.p2, H, p.p1);

	if( val < 0 )
		CommonOps.scale(-1, H);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:13,代码来源:AdjustHomographyMatrix.java

示例9: massageResults

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
 * <p>
 * Since the linear solution is probably not an exact rotation matrix, this code finds the best
 * approximation.
 * </p>
 *
 * See page 280 of [1]
 */
private void massageResults() {
	DenseMatrix64F R = motion.getR();
	Vector3D_F64 T = motion.getT();

	if( !svd.decompose(R))
		throw new RuntimeException("SVD Failed");

	CommonOps.multTransB(svd.getU(null,false),svd.getV(null,false),R);

	// determinant should be +1
	double det = CommonOps.det(R);

	if( det < 0 )
		CommonOps.scale(-1,R);

	// compute the determinant of the singular matrix
	double b = 1.0;
	double s[] = svd.getSingularValues();

	for( int i = 0; i < svd.numberOfSingularValues(); i++ ) {
		b *= s[i];
	}

	b = Math.signum(det)/Math.pow(b,1.0/3.0);

	GeometryMath_F64.scale(T,b);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:36,代码来源:PoseFromPairLinear6.java

示例10: solveForXandY

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
 * Once z is known then x and y can be solved for using the B matrix
 */
private void solveForXandY( double z ) {
	this.z = z;

	DenseMatrix64F A = new DenseMatrix64F(3,2);
	DenseMatrix64F Y = new DenseMatrix64F(3,1);

	// solve for x and y using the first two rows of B
	A.data[0] = ((helper.K00*z + helper.K01)*z + helper.K02)*z + helper.K03;
	A.data[1] = ((helper.K04*z + helper.K05)*z + helper.K06)*z + helper.K07;
	Y.data[0] = (((helper.K08*z + helper.K09)*z + helper.K10)*z + helper.K11)*z + helper.K12;

	A.data[2] = ((helper.L00*z + helper.L01)*z + helper.L02)*z + helper.L03;
	A.data[3] = ((helper.L04*z + helper.L05)*z + helper.L06)*z + helper.L07;
	Y.data[1] = (((helper.L08*z + helper.L09)*z + helper.L10)*z + helper.L11)*z + helper.L12;

	A.data[4] = ((helper.M00*z + helper.M01)*z + helper.M02)*z + helper.M03;
	A.data[5] = ((helper.M04*z + helper.M05)*z + helper.M06)*z + helper.M07;
	Y.data[2] = (((helper.M08*z + helper.M09)*z + helper.M10)*z + helper.M11)*z + helper.M12;

	CommonOps.scale(-1,Y);

	DenseMatrix64F x = new DenseMatrix64F(2,1);

	CommonOps.solve(A,Y,x);

	this.x = x.get(0,0);
	this.y = x.get(1,0);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:32,代码来源:EssentialNister5.java

示例11: setModel

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
@Override
public void setModel(DenseMatrix64F F )
{
	// assume that each element in the matrix has equal weight
	double v = CommonOps.elementSumAbs(F);
	CommonOps.scale(1.0/v,F,M);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:8,代码来源:DistanceEpipolarConstraint.java

示例12: decomposeCameraMatrix

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
 * <p>
 * Decomposes a camera matrix P=A*[R|T], where A is an upper triangular camera calibration
 * matrix, R is a rotation matrix, and T is a translation vector.
 *
 * <ul>
 * <li> NOTE: There are multiple valid solutions to this problem and only one solution is returned.
 * <li> NOTE: The camera center will be on the plane at infinity.
 * </ul>
 * </p>
 *
 * @param P Input: Camera matrix, 3 by 4
 * @param K Output: Camera calibration matrix, 3 by 3.
 * @param pose Output: The rotation and translation.
 */
public static void decomposeCameraMatrix(DenseMatrix64F P, DenseMatrix64F K, Se3_F64 pose) {
	DenseMatrix64F KR = new DenseMatrix64F(3,3);
	CommonOps.extract(P, 0, 3, 0, 3, KR, 0, 0);

	QRDecomposition<DenseMatrix64F> qr = DecompositionFactory.qr(3, 3);

	if( !CommonOps.invert(KR) )
		throw new RuntimeException("Inverse failed!  Bad input?");

	if( !qr.decompose(KR) )
		throw new RuntimeException("QR decomposition failed!  Bad input?");

	DenseMatrix64F U = qr.getQ(null,false);
	DenseMatrix64F B = qr.getR(null, false);

	if( !CommonOps.invert(U,pose.getR()) )
		throw new RuntimeException("Inverse failed!  Bad input?");

	Point3D_F64 KT = new Point3D_F64(P.get(0,3),P.get(1,3),P.get(2,3));
	GeometryMath_F64.mult(B, KT, pose.getT());

	if( !CommonOps.invert(B,K) )
		throw new RuntimeException("Inverse failed!  Bad input?");

	CommonOps.scale(1.0/K.get(2,2),K);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:42,代码来源:MultiViewOps.java

示例13: normalizeScale

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
 * The scale of the trifocal tensor is arbitrary.  However there are situations when comparing results that
 * using a consistent scale is useful.  This function normalizes the sensor such that its Euclidean length
 * (the f-norm) is equal to one.
 */
public void normalizeScale() {
	double sum = 0;

	sum += SpecializedOps.elementSumSq(T1);
	sum += SpecializedOps.elementSumSq(T2);
	sum += SpecializedOps.elementSumSq(T3);

	double n = Math.sqrt(sum);

	CommonOps.scale(1.0/n,T1);
	CommonOps.scale(1.0/n,T2);
	CommonOps.scale(1.0/n,T3);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:19,代码来源:TrifocalTensor.java

示例14: compareWithKnown

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
 * Compare results from rectified transform and a set of camera which are already rectified.
 */
@Test
public void compareWithKnown() {
	DenseMatrix64F K = new DenseMatrix64F(3,3,true,300,0,200,0,400,205,0,0,1);

	// transforms are world to camera, but I'm thinking camera to world, which is why invert
	Se3_F64 poseR1 = createPose(0,0,0,  0.1,0,0.1).invert(null);
	Se3_F64 poseR2 = createPose(0,0,0,  1  ,0,0.1).invert(null);

	// only rotate around the y-axis so that the rectified coordinate system will have to be
	// the same as the global
	Se3_F64 poseA1 = createPose(0,0.05,0,   0.1,0,0.1).invert(null);
	Se3_F64 poseA2 = createPose(0,-0.1,0,   1  ,0,0.1).invert(null);

	RectifyCalibrated alg = new RectifyCalibrated();
	alg.process(K,poseA1,K,poseA2);

	// original camera matrix
	DenseMatrix64F foundP1 = PerspectiveOps.createCameraMatrix(poseA1.getR(),poseA1.getT(),K,null);
	DenseMatrix64F foundP2 = PerspectiveOps.createCameraMatrix(poseA2.getR(),poseA2.getT(),K,null);

	// apply rectification transform
	DenseMatrix64F temp = new DenseMatrix64F(3,4);
	CommonOps.mult(alg.getRect1(),foundP1,temp);
	foundP1.set(temp);
	CommonOps.mult(alg.getRect2(),foundP2,temp);
	foundP2.set(temp);

	CommonOps.scale(0.1/Math.abs(foundP1.get(2,3)),foundP1);

	Point3D_F64 X = new Point3D_F64(0,0,3);

	// compare results, both should match because of rotation only being around y-axis
	assertEquals(PerspectiveOps.renderPixel(poseR1,K,X).x,PerspectiveOps.renderPixel(foundP1,X).x,1e-5);
	assertEquals(PerspectiveOps.renderPixel(poseR1,K,X).y,PerspectiveOps.renderPixel(foundP1,X).y,1e-5);
	assertEquals(PerspectiveOps.renderPixel(poseR2,K,X).x,PerspectiveOps.renderPixel(foundP2,X).x,1e-5);
	assertEquals(PerspectiveOps.renderPixel(poseR2,K,X).y,PerspectiveOps.renderPixel(foundP2,X).y,1e-5);
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:41,代码来源:TestRectifyCalibrated.java

示例15: canonicalCamera

import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
@Test
public void canonicalCamera() {
	DenseMatrix64F K = PerspectiveOps.calibrationMatrix(200, 250, 0, 100, 110);
	DenseMatrix64F R = RotationMatrixGenerator.eulerXYZ(1,2,-0.5,null);
	Vector3D_F64 T = new Vector3D_F64(0.5,0.7,-0.3);

	DenseMatrix64F E = MultiViewOps.createEssential(R, T);
	DenseMatrix64F F = MultiViewOps.createFundamental(E, K);

	Point3D_F64 e1 = new Point3D_F64();
	Point3D_F64 e2 = new Point3D_F64();

	CommonOps.scale(-2.0/F.get(0,1),F);
	MultiViewOps.extractEpipoles(F, e1, e2);

	DenseMatrix64F P = MultiViewOps.canonicalCamera(F, e2, new Vector3D_F64(1, 1, 1), 2);

	// recompose the fundamental matrix using the special equation for canonical cameras
	DenseMatrix64F foundF = new DenseMatrix64F(3,3);
	DenseMatrix64F crossEpi = new DenseMatrix64F(3,3);

	GeometryMath_F64.crossMatrix(e2, crossEpi);

	DenseMatrix64F M = new DenseMatrix64F(3,3);
	CommonOps.extract(P,0,3,0,3,M,0,0);
	CommonOps.mult(crossEpi,M,foundF);

	// see if they are equal up to a scale factor
	CommonOps.scale(1.0 / foundF.get(0, 1), foundF);
	CommonOps.scale(1.0 / F.get(0, 1), F);

	assertTrue(MatrixFeatures.isIdentical(F,foundF,1e-8));
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:34,代码来源:TestMultiViewOps.java


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