本文整理汇总了Java中org.apache.commons.math3.linear.RealMatrix.operate方法的典型用法代码示例。如果您正苦于以下问题:Java RealMatrix.operate方法的具体用法?Java RealMatrix.operate怎么用?Java RealMatrix.operate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.linear.RealMatrix
的用法示例。
在下文中一共展示了RealMatrix.operate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.commons.math3.linear.RealMatrix; //导入方法依赖的package包/类
public static void main(String[] args) {
int NDIGITS = 1;
double scale = 3.5;
System.out.println("original scale = " + scale);
double alpha = 0.6;
double[][] R0data =
{{ Math.cos(alpha), -Math.sin(alpha) },
{ Math.sin(alpha), Math.cos(alpha) }};
RealMatrix R0 = MatrixUtils.createRealMatrix(R0data);
System.out.println("original R = \n" + Matrix.toString(R0.getData()));
double[] t0 = {4, -3};
System.out.println("original t = " + Matrix.toString(t0));
List<double[]> X = new ArrayList<double[]>();
List<double[]> Y = new ArrayList<double[]>();
X.add(new double[] {2, 5});
X.add(new double[] {7, 3});
X.add(new double[] {0, 9});
X.add(new double[] {5, 4});
for (double[] a : X) {
double[] b = R0.operate(a);
b[0] = roundToDigits(scale * b[0] + t0[0], NDIGITS);
b[1] = roundToDigits(scale * b[1] + t0[1], NDIGITS);
Y.add(b);
}
boolean allowTranslation = true;
boolean allowScaling = true;
boolean forceRotation = true;
ProcrustesFit pf = new ProcrustesFit(allowTranslation, allowScaling, forceRotation);
pf.fit(X, Y);
System.out.println("R = \n" + Matrix.toString(pf.getR().getData()));
System.out.println("t = " + Matrix.toString(pf.getT().toArray()));
System.out.format("c = %.3f\n", pf.getScale());
System.out.format("err1 = %.3f\n", pf.getError());
RealMatrix M = pf.getTransformationMatrix();
System.out.println("M = \n" + Matrix.toString(M.getData()));
}