本文整理汇总了Java中org.ejml.ops.CommonOps.mult方法的典型用法代码示例。如果您正苦于以下问题:Java CommonOps.mult方法的具体用法?Java CommonOps.mult怎么用?Java CommonOps.mult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ejml.ops.CommonOps
的用法示例。
在下文中一共展示了CommonOps.mult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCameraMatrix
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
* Create a 3x4 camera matrix. For calibrated camera P = [R|T]. For uncalibrated camera it is P = K*[R|T].
*
* @param R Rotation matrix. 3x3
* @param T Translation vector.
* @param K Optional camera calibration matrix 3x3.
* @param ret Storage for camera calibration matrix. If null a new instance will be created.
* @return Camera calibration matrix.
*/
public static DenseMatrix64F createCameraMatrix( DenseMatrix64F R , Vector3D_F64 T , DenseMatrix64F K ,
DenseMatrix64F ret ) {
if( ret == null )
ret = new DenseMatrix64F(3,4);
CommonOps.insert(R,ret,0,0);
ret.data[3] = T.x;
ret.data[7] = T.y;
ret.data[11] = T.z;
if( K == null )
return ret;
DenseMatrix64F temp = new DenseMatrix64F(3,4);
CommonOps.mult(K,ret,temp);
ret.set(temp);
return ret;
}
示例2: extractTransform
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
* There are four possible reconstructions from an essential matrix. This function will compute different
* permutations depending on optionA and optionB being true or false.
*/
private void extractTransform( DenseMatrix64F U , DenseMatrix64F V , DenseMatrix64F S ,
Se3_F64 se , boolean optionA , boolean optionB )
{
DenseMatrix64F R = se.getR();
Vector3D_F64 T = se.getT();
// extract rotation
if( optionA )
CommonOps.mult(U,Rz,temp);
else
CommonOps.multTransB(U,Rz,temp);
CommonOps.multTransB(temp,V,R);
// extract screw symmetric translation matrix
if( optionB )
CommonOps.multTransB(U,Rz,temp);
else
CommonOps.mult(U,Rz,temp);
CommonOps.mult(temp,S,temp2);
CommonOps.multTransB(temp2,U,temp);
T.x = temp.get(2,1);
T.y = temp.get(0,2);
T.z = temp.get(1,0);
}
示例3: projectOntoEssential
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
* Projects the found estimate of E onto essential space.
*
* @return true if svd returned true.
*/
protected boolean projectOntoEssential( DenseMatrix64F E ) {
if( !svdConstraints.decompose(E) ) {
return false;
}
svdV = svdConstraints.getV(svdV,false);
svdU = svdConstraints.getU(svdU,false);
svdS = svdConstraints.getW(svdS);
SingularOps.descendingOrder(svdU, false, svdS, svdV, false);
// project it into essential space
// the scale factor is arbitrary, but the first two singular values need
// to be the same. so just set them to one
svdS.unsafe_set(0, 0, 1);
svdS.unsafe_set(1, 1, 1);
svdS.unsafe_set(2, 2, 0);
// recompute F
CommonOps.mult(svdU, svdS, temp0);
CommonOps.multTransB(temp0,svdV, E);
return true;
}
示例4: projectOntoFundamentalSpace
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
* Projects the found estimate of F onto Fundamental space.
*
* @return true if svd returned true.
*/
protected boolean projectOntoFundamentalSpace( DenseMatrix64F F ) {
if( !svdConstraints.decompose(F) ) {
return false;
}
svdV = svdConstraints.getV(svdV,false);
svdU = svdConstraints.getU(svdU,false);
svdS = svdConstraints.getW(svdS);
SingularOps.descendingOrder(svdU, false, svdS, svdV, false);
// the smallest singular value needs to be set to zero, unlike
svdS.set(2, 2, 0);
// recompute F
CommonOps.mult(svdU, svdS, temp0);
CommonOps.multTransB(temp0,svdV, F);
return true;
}
示例5: constraint
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
* <p>
* Trifocal tensor with point-point-line correspondence:<br>
* [p2]<sub>x</sub>(sum p1<sup>i</sup>*T<sub>i</sub>)*l3 = 0
* </p>
*
* @param tensor Trifocal tensor
* @param p1 A point in the first view.
* @param p2 A point in the second view.
* @param l3 A line in the third view.
* @return Result of applying the constraint. With perfect inputs will be zero.
*/
public static Vector3D_F64 constraint(TrifocalTensor tensor,
Point2D_F64 p1, Point2D_F64 p2, Vector3D_F64 l3,
Vector3D_F64 ret)
{
if( ret == null )
ret = new Vector3D_F64();
DenseMatrix64F sum = new DenseMatrix64F(3,3);
CommonOps.add(p1.x,tensor.T1,sum,sum);
CommonOps.add(p1.y,tensor.T2,sum,sum);
CommonOps.add(tensor.T3,sum,sum);
DenseMatrix64F cross2 = GeometryMath_F64.crossMatrix(p2.x,p2.y,1,null);
DenseMatrix64F temp = new DenseMatrix64F(3,3);
CommonOps.mult(cross2,sum,temp);
GeometryMath_F64.mult(temp, l3, ret);
return ret;
}
示例6: createHomography
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
* <p>
* Computes a homography matrix from a rotation, translation, plane normal, plane distance, and
* calibration matrix:<br>
* H = K*(R+(1/d)*T*N<sup>T</sup>)*K<sup>-1</sup>
* </p>
*
* @param R Rotation matrix.
* @param T Translation vector.
* @param d Distance of closest point on plane to camera
* @param N Normal of plane
* @param K Intrinsic calibration matrix
* @return Uncalibrated homography matrix
*/
public static DenseMatrix64F createHomography(DenseMatrix64F R, Vector3D_F64 T,
double d, Vector3D_F64 N,
DenseMatrix64F K)
{
DenseMatrix64F temp = new DenseMatrix64F(3,3);
DenseMatrix64F K_inv = new DenseMatrix64F(3,3);
DenseMatrix64F H = createHomography(R, T, d, N);
// apply calibration matrix to R
CommonOps.mult(K,H,temp);
CommonOps.invert(K,K_inv);
CommonOps.mult(temp,K_inv,H);
return H;
}
示例7: mtimes
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
public Matrix mtimes(Matrix m) {
if (m instanceof EJMLDenseDoubleMatrix2D) {
DenseMatrix64F b = ((EJMLDenseDoubleMatrix2D) m).getWrappedObject();
DenseMatrix64F ret = new DenseMatrix64F(matrix.numRows, b.numCols);
CommonOps.mult(matrix, b, ret);
return new EJMLDenseDoubleMatrix2D(ret);
} else {
return super.mtimes(m);
}
}
示例8: 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.subtract(s, mean, s);
CommonOps.mult(V_t,s,r);
return r.data;
}
示例9: response
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
* Computes the dot product of each basis vector against the sample. Can be used as a measure
* for membership in the training sample set. High values correspond to a better fit.
*
* @param sample Sample of original data.
* @return Higher value indicates it is more likely to be a member of input dataset.
*/
public double response( double[] sample ) {
if( sample.length != A.numCols )
throw new IllegalArgumentException("Expected input vector to be in sample space");
DenseMatrix64F dots = new DenseMatrix64F(numComponents,1);
DenseMatrix64F s = DenseMatrix64F.wrap(A.numCols,1,sample);
CommonOps.mult(V_t,s,dots);
return NormOps.normF(dots);
}
示例10: getExponentTerm
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
private double getExponentTerm(double[] features) {
DenseMatrix64F ft =new DenseMatrix64F(1,features.length);
for(int i=0;i<features.length;i++){
ft.set(0,i,features[i]-avg[i]);
}
DenseMatrix64F ft2=new DenseMatrix64F(1,features.length);
CommonOps.mult(ft, inv, ft2);
DenseMatrix64F ft3=new DenseMatrix64F(1,1);
CommonOps.multTransB(1, ft2, ft, ft3);
return FastMath.exp(-0.5 *ft3.get(0,0));
}
示例11: rotationCenteredMtx
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
*
* @param R
* @param center
* @return
*/
public static DenseMatrix64F rotationCenteredMtx( DenseMatrix64F R, double[] center)
{
int ndims = center.length;
logger.debug("R " + R);
DenseMatrix64F affineXfm = new DenseMatrix64F( ndims + 1, ndims + 1 );
DenseMatrix64F res = new DenseMatrix64F( ndims, 1 );
DenseMatrix64F ctrVec = new DenseMatrix64F( ndims, 1 );
ctrVec.setData( center );
CommonOps.changeSign(ctrVec);
CommonOps.mult(R, ctrVec, res);
CommonOps.insert( R, affineXfm, 0, 0);
CommonOps.insert(res, affineXfm, 0, ndims);
affineXfm.set( ndims, ndims, 1 );
CommonOps.changeSign(ctrVec);
for (int i = 0; i < ndims; i++) {
affineXfm.set(i, ndims,
affineXfm.get(i,ndims) + ctrVec.get(i));
}
return affineXfm;
}
示例12: rotationPca
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
* Computes a rotation transformation from the source to target.
* @param src
* @param tgt
* @return
*/
public static <T extends RealType<T>> AffineTransform rotationPca(
IterableInterval<T> src, IterableInterval<T> tgt ){
int ndims = src.numDimensions();
ImgMoment srcMom = new ImgMoment();
double[] srcOr = srcMom.orientation(src);
srcMom.orientationEvalsEvecs(srcOr);
ImgMoment tgtMom = new ImgMoment();
double[] tgtOr = tgtMom.orientation(tgt);
tgtMom.orientationEvalsEvecs(tgtOr);
DenseMatrix64F srcR = new DenseMatrix64F( ndims, ndims );
srcR.setData( srcMom.getEvecs() );
DenseMatrix64F srcMtx = rotationCenteredMtx(srcR, srcMom.centroid());
DenseMatrix64F tgtR = new DenseMatrix64F( ndims, ndims );
tgtR.setData( tgtMom.getEvecs() );
DenseMatrix64F tgtMtx = rotationCenteredMtx(tgtR, tgtMom.centroid());
DenseMatrix64F res = new DenseMatrix64F( ndims+1, ndims+1 );
// CommonOps.invert(srcMtx);
// CommonOps.mult( tgtMtx, srcMtx, res );
CommonOps.invert(tgtMtx);
CommonOps.mult( srcMtx, tgtMtx, res );
return toAffineTransform(res);
}
示例13: 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;
}
示例14: response
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
/**
* Computes the dot product of each basis vector against the sample. Can be used as a measure
* for membership in the training sample set. High values correspond to a better fit.
*
* @param sample Sample of original data.
* @return Higher value indicates it is more likely to be a member of input dataset.
*/
public double response( double[] sample ) {
if( sample.length != A.numCols )
throw new IllegalArgumentException("Expected input vector to be in sample space");
DenseMatrix64F dots = new DenseMatrix64F(numComponents,1);
DenseMatrix64F s = DenseMatrix64F.wrap(A.numCols,1,sample);
CommonOps.mult(V_t,s,dots);
return NormOps.normF(dots);
}
示例15: checkNumControl
import org.ejml.ops.CommonOps; //导入方法依赖的package包/类
private void checkNumControl(int numControl ) {
createInputs(numControl);
Relinearlize alg = new Relinearlize();
alg.setNumberControl(numControl);
// variables being estimated
double foundBeta[] = new double[numControl];
alg.process(L_full,y,foundBeta);
// check to see if its a valid solution
DenseMatrix64F x = new DenseMatrix64F(L_full.numCols,1);
DenseMatrix64F foundDistance = new DenseMatrix64F(L_full.numRows,1);
int index = 0;
for( int i = 0; i < numControl; i++ ) {
for( int j = i; j < numControl; j++ ) {
x.data[index++] = foundBeta[i]*foundBeta[j];
}
}
CommonOps.mult(L_full, x, foundDistance);
// System.out.println("error = "+SpecializedOps.diffNormF(foundDistance,y));
// NOTE: This test can pass and the result still be bad because L_full is
// an undetermined system. But at least there is some sort of test here
assertTrue(MatrixFeatures.isEquals(foundDistance, y, 2));
// WARNING!!! the error margin was made to be huge to make sure it passed
}