本文整理汇总了Java中org.ejml.ops.CommonOps.sub方法的典型用法代码示例。如果您正苦于以下问题:Java CommonOps.sub方法的具体用法?Java CommonOps.sub怎么用?Java CommonOps.sub使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ejml.ops.CommonOps
的用法示例。
在下文中一共展示了CommonOps.sub方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sampleToEigenSpace
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
* Converts a vector from sample space into eigen space.
*
* @param sampleData Sample space data.
* @return Eigen space projection.
*/
public double[] sampleToEigenSpace(double[] sampleData) {
if (sampleData.length != getDataMatrix().getNumCols()) {
throw new IllegalArgumentException("Unexpected sample length");
}
DenseMatrix64F mean = DenseMatrix64F.wrap(getDataMatrix().getNumCols(), 1, this.getMean());
DenseMatrix64F s = new DenseMatrix64F(getDataMatrix().getNumCols(), 1, true, sampleData);
DenseMatrix64F r = new DenseMatrix64F(getNumPrincipalComponents(), 1);
CommonOps.sub(s, mean, s);
CommonOps.mult(getPrincipalComponentSubspace(), s, r);
return r.data;
}
示例2: sampleToEigenSpace
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
* Converts a vector from sample space into eigen space. If {@link #doWhitening} is true, then the vector
* is also L2 normalized after projection.
*
* @param sampleData
* Sample space vector
* @return Eigen space projected vector
* @throws Exception
*/
public double[] sampleToEigenSpace(double[] sampleData) throws Exception {
if (!isPcaInitialized) {
// initiallize PCA correctly!
throw new Exception("PCA is not correctly initiallized!");
}
if (sampleData.length != sampleSize) {
throw new IllegalArgumentException("Unexpected vector length!");
}
DenseMatrix64F sample = new DenseMatrix64F(sampleSize, 1, true, sampleData);
DenseMatrix64F projectedSample = new DenseMatrix64F(numComponents, 1);
// mean subtraction
CommonOps.sub(sample, means, sample);
// projection
CommonOps.mult(V_t, sample, projectedSample);
// whitening
if (doWhitening) { // always perform this normalization step when whitening is used
return Normalization.normalizeL2(projectedSample.data);
} else {
return projectedSample.data;
}
}
示例3: sampleToEigenSpace
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
* Converts a vector from sample space into eigen space.
*
* @param sampleData Sample space data.
* @return Eigen space projection.
*/
public double[] sampleToEigenSpace( double[] sampleData ) {
if( sampleData.length != A.getNumCols() )
throw new IllegalArgumentException("Unexpected sample length");
DenseMatrix64F mean = DenseMatrix64F.wrap(A.getNumCols(),1,this.mean);
DenseMatrix64F s = new DenseMatrix64F(A.getNumCols(),1,true,sampleData);
DenseMatrix64F r = new DenseMatrix64F(numComponents,1);
CommonOps.sub(s,mean,s);
CommonOps.mult(V_t,s,r);
return r.data;
}
示例4: setupA
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
* Sets up the system of equations which are to be solved. This equation is derived from
* constraints (3) and (4) in the paper. See section 3.1.
*
* @param homographies set of observed homographies.
*/
private void setupA( List<DenseMatrix64F> homographies ) {
A.reshape(2*homographies.size(),6, false);
DenseMatrix64F h1 = new DenseMatrix64F(3,1);
DenseMatrix64F h2 = new DenseMatrix64F(3,1);
DenseMatrix64F v12 = new DenseMatrix64F(1,6);
DenseMatrix64F v11 = new DenseMatrix64F(1,6);
DenseMatrix64F v22 = new DenseMatrix64F(1,6);
DenseMatrix64F v11m22 = new DenseMatrix64F(1,6);
for( int i = 0; i < homographies.size(); i++ ) {
DenseMatrix64F H = homographies.get(i);
CommonOps.extract(H,0,3,0,1,h1,0,0);
CommonOps.extract(H,0,3,1,2,h2,0,0);
// normalize H by the max value to reduce numerical error when computing A
// several numbers are multiplied against each other and could become quite large/small
double max1 = CommonOps.elementMaxAbs(h1);
double max2 = CommonOps.elementMaxAbs(h2);
double max = Math.max(max1,max2);
CommonOps.divide(max,h1);
CommonOps.divide(max,h2);
// compute elements of A
computeV(h1, h2, v12);
computeV(h1, h1, v11);
computeV(h2, h2, v22);
CommonOps.sub(v11,v22,v11m22);
CommonOps.insert( v12 , A, i*2 , 0);
CommonOps.insert( v11m22 , A, i*2+1 , 0);
}
}
示例5: setupA_NoSkew
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
* Similar to {@link #setupA(java.util.List)} but all references to B12 have been removed
* since it will always be zero when the skew is zero
*
* @param homographies set of observed homographies.
*/
private void setupA_NoSkew( List<DenseMatrix64F> homographies ) {
A.reshape(2*homographies.size(),5, false);
DenseMatrix64F h1 = new DenseMatrix64F(3,1);
DenseMatrix64F h2 = new DenseMatrix64F(3,1);
DenseMatrix64F v12 = new DenseMatrix64F(1,5);
DenseMatrix64F v11 = new DenseMatrix64F(1,5);
DenseMatrix64F v22 = new DenseMatrix64F(1,5);
DenseMatrix64F v11m22 = new DenseMatrix64F(1,5);
for( int i = 0; i < homographies.size(); i++ ) {
DenseMatrix64F H = homographies.get(i);
CommonOps.extract(H,0,3,0,1,h1,0,0);
CommonOps.extract(H,0,3,1,2,h2,0,0);
// normalize H by the max value to reduce numerical error when computing A
// several numbers are multiplied against each other and could become quite large/small
double max1 = CommonOps.elementMaxAbs(h1);
double max2 = CommonOps.elementMaxAbs(h2);
double max = Math.max(max1,max2);
CommonOps.divide(max,h1);
CommonOps.divide(max,h2);
// compute elements of A
computeV_NoSkew(h1, h2, v12);
computeV_NoSkew(h1, h1, v11);
computeV_NoSkew(h2, h2, v22);
CommonOps.sub(v11,v22,v11m22);
CommonOps.insert( v12 , A, i*2 , 0);
CommonOps.insert( v11m22 , A, i*2+1 , 0);
}
}
示例6: createSolution
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
* R = W*U^T
* N = v2 cross u
* (1/d)*T = (H-R)*N
*/
private void createSolution( DenseMatrix64F W , DenseMatrix64F U , Vector3D_F64 u ,
DenseMatrix64F H ,
Se3_F64 se , Vector3D_F64 N )
{
CommonOps.multTransB(W,U,se.getR());
GeometryMath_F64.cross(v2,u,N);
CommonOps.sub(H, se.getR(),tempM);
GeometryMath_F64.mult(tempM,N,se.getT());
}
示例7: process
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
* Computes the homography based on two unique lines on the plane
*
* @param line0 Line on the plane
* @param line1 Line on the plane
*/
public boolean process(PairLineNorm line0, PairLineNorm line1) {
// Find plane equations of second lines in the first view
double a0 = GeometryMath_F64.dot(e2,line0.l2);
double a1 = GeometryMath_F64.dot(e2,line1.l2);
GeometryMath_F64.multTran(A,line0.l2,Al0);
GeometryMath_F64.multTran(A,line1.l2,Al1);
// find the intersection of the planes created by each view of each line
// first line
planeA.set( line0.l1.x , line0.l1.y , line0.l1.z , 0 );
planeB.set( Al0.x , Al0.y , Al0.z , a0 );
if( !Intersection3D_F64.intersect(planeA,planeB,intersect0) )
return false;
intersect0.slope.normalize(); // maybe this will reduce overflow problems?
// second line
planeA.set( line1.l1.x , line1.l1.y , line1.l1.z , 0 );
planeB.set( Al1.x , Al1.y , Al1.z , a1 );
if( !Intersection3D_F64.intersect(planeA,planeB,intersect1) )
return false;
intersect1.slope.normalize();
// compute the plane defined by these two lines
from0to1.x = intersect1.p.x - intersect0.p.x;
from0to1.y = intersect1.p.y - intersect0.p.y;
from0to1.z = intersect1.p.z - intersect0.p.z;
// the plane's normal will be the cross product of one of the slopes and a line connecting the two lines
GeometryMath_F64.cross(intersect0.slope,from0to1,pi.n);
pi.p.set(intersect0.p);
// convert this plane description into general format
UtilPlane3D_F64.convert(pi,pi_gen);
v.set(pi_gen.A/pi_gen.D,pi_gen.B/pi_gen.D,pi_gen.C/pi_gen.D);
// H = A - e2*v^T
GeometryMath_F64.outerProd(e2,v,av);
CommonOps.sub(A,av,H);
// pick a good scale and sign for H
adjust.adjust(H, line0);
return true;
}