本文整理汇总了Java中org.apache.commons.math3.linear.BlockRealMatrix.setEntry方法的典型用法代码示例。如果您正苦于以下问题:Java BlockRealMatrix.setEntry方法的具体用法?Java BlockRealMatrix.setEntry怎么用?Java BlockRealMatrix.setEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.linear.BlockRealMatrix
的用法示例。
在下文中一共展示了BlockRealMatrix.setEntry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculate
import org.apache.commons.math3.linear.BlockRealMatrix; //导入方法依赖的package包/类
@Override
public RealMatrix calculate(final IterableRegion<B> input) {
final BlockRealMatrix output = new BlockRealMatrix(3, 3);
Cursor<Void> c = input.localizingCursor();
double[] pos = new double[3];
double[] computedCentroid = new double[3];
centroid.calculate(input).localize(computedCentroid);
final double mX = computedCentroid[0];
final double mY = computedCentroid[1];
final double mZ = computedCentroid[2];
while (c.hasNext()) {
c.fwd();
c.localize(pos);
output.setEntry(0, 0, output.getEntry(0, 0) + (pos[0] - mX) * (pos[0] - mX));
output.setEntry(1, 1, output.getEntry(1, 1) + (pos[1] - mX) * (pos[1] - mY));
output.setEntry(2, 2, output.getEntry(2, 2) + (pos[2] - mX) * (pos[2] - mZ));
output.setEntry(0, 1, output.getEntry(0, 1) + (pos[0] - mY) * (pos[1] - mY));
output.setEntry(1, 0, output.getEntry(0, 1));
output.setEntry(0, 2, output.getEntry(0, 2) + (pos[0] - mY) * (pos[2] - mZ));
output.setEntry(2, 0, output.getEntry(0, 2));
output.setEntry(1, 2, output.getEntry(1, 2) + (pos[1] - mZ) * (pos[2] - mZ));
output.setEntry(2, 1, output.getEntry(1, 2));
}
final double size = input.size();
output.setEntry(0, 0, output.getEntry(0, 0) / size);
output.setEntry(0, 1, output.getEntry(0, 1) / size);
output.setEntry(0, 2, output.getEntry(0, 2) / size);
output.setEntry(1, 0, output.getEntry(1, 0) / size);
output.setEntry(1, 1, output.getEntry(1, 1) / size);
output.setEntry(1, 2, output.getEntry(1, 2) / size);
output.setEntry(2, 0, output.getEntry(2, 0) / size);
output.setEntry(2, 1, output.getEntry(2, 1) / size);
output.setEntry(2, 2, output.getEntry(2, 2) / size);
return output;
}
示例2: convertToApacheMatrix
import org.apache.commons.math3.linear.BlockRealMatrix; //导入方法依赖的package包/类
public static RealMatrix convertToApacheMatrix(INDArray matrix) {
if (matrix.rank() != 2)
throw new IllegalArgumentException("Input rank is not 2 (not matrix)");
int[] shape = matrix.shape();
BlockRealMatrix out = new BlockRealMatrix(shape[0], shape[1]);
for (int i = 0; i < shape[0]; i++) {
for (int j = 0; j < shape[1]; j++) {
double value = matrix.getDouble(i, j);
out.setEntry(i, j, value);
}
}
return out;
}