本文整理汇总了Java中org.apache.commons.math.linear.RealVector.add方法的典型用法代码示例。如果您正苦于以下问题:Java RealVector.add方法的具体用法?Java RealVector.add怎么用?Java RealVector.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math.linear.RealVector
的用法示例。
在下文中一共展示了RealVector.add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPlus
import org.apache.commons.math.linear.RealVector; //导入方法依赖的package包/类
@Test
public void testPlus() throws Exception {
final int r = 4, c = 12;
final RealMatrix cn1 = createRealMatrix(r, c, 1.0),
cn2 = createRealMatrix(r, c, 14.2),
un1 = createRealMatrix(r, c, 12.1),
un2 = createRealMatrix(r, c, 5.42),
cs1 = createRealMatrix(r, c, 0.7),
cs2 = createRealMatrix(r, c, 2.74),
us1 = createRealMatrix(r, c, 7.7),
us2 = createRealMatrix(r, c, 3.14),
bl1 = createRealMatrix(r, c, 14.1),
bl2 = createRealMatrix(r, c, 1.4);
for(int i = 0; i < r; i++) {
bl1.setEntry(i, 0, 0);
bl1.setEntry(i, 0, 1);
}
final double[] stateArr = new double[] {1, 20, 40, 80};
final RealVector state = new ArrayRealVector(stateArr);
final RealVector cov1 = createRealVector(c, 1.0);
final RealVector cov2 = createRealVector(c, 1.0);
final StarTreeTraces t1 = new StarTreeTraces(state, cn1, cs1, un1, us1, cov1.toArray(), bl1),
t2 = new StarTreeTraces(state, cn2, cs2, un2, us2, cov2.toArray(), bl2);
final StarTreeTraces summed = t1.plus(t2);
checkSum(cn1, cn2, summed.getConditionalNonsynonymous());
checkSum(un1, un2, summed.getUnconditionalNonsynonymous());
checkSum(cs1, cs2, summed.getConditionalSynonymous());
checkSum(us1, us2, summed.getUnconditionalSynonymous());
checkSum(bl1, bl2, summed.getTotalBranchLength());
final RealVector totalCov = cov1.add(cov2);
Assert.assertArrayEquals(totalCov.getData(), summed.getCoverage().getData(), TOL);
}