在 OjAlgo 的特定列和行的 Primitive64Store 中插入 Access2D 元素

Insert Access2D element in Primitive64Store in OjAlgo at specific column and row

是否可以在 OjAlgo 的 Primitive64Store 中插入 Access2D 元素?

    Access2D<Double> data = Access2D.wrap(mu.toRawCopy2D());
    Primitive64Store B = Primitive64Store.FACTORY.make(rows * m, columns * n);

我想将数据插入到 B 中的特定起始行和起始列。

暂时。我已经实现了这样的程序:

public class Repmat {

    static public MatrixStore<Double> repmat(MatrixStore<Double> mu, int m, int n) {
        long rows = mu.countRows();
        long columns = mu.countColumns();
        double[][] data = mu.toRawCopy2D();
        Primitive64Store B = Primitive64Store.FACTORY.make(rows * m, columns * n);
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                for(int k = 0; k < rows; k++) {
                    B.fillRow(i * rows + k, j * columns, Access1D.wrap(data[k])); // Get row from data and place it into B
                }
            }
        }
        return B.get();
    }
} 

但这一定是更好的方法吗?

也许是这样的:

static public MatrixStore<Double> repmat(MatrixStore<Double> mu, int m, int n) {

    LogicalBuilder<Double> builder = mu.logical();

    for (int i = 1; i < m; i++) {
        builder.below(mu);
    }

    MatrixStore<Double> firstCol = builder.get();

    for (int j = 1; j < n; j++) {
        builder.right(firstCol);
    }

    return builder.get();
}