jblas-project / jblas

Linear Algebra for Java
http://jblas.org
BSD 3-Clause "New" or "Revised" License
590 stars 149 forks source link

Matrix put with ranges #75

Open GooKv opened 8 years ago

GooKv commented 8 years ago

These checks assume sizes of ranges to have exactly the same size as the matrix has. This way it is impossible to fill some part of the matrix with the other one (say a vector), you can only fill the whole matrix with the other one of the same size.

public DoubleMatrix put(Range rs, Range cs, DoubleMatrix x) {
        rs.init(0, rows);
        cs.init(0, columns);

        x.checkRows(rs.length());
        x.checkColumns(cs.length());

        for (; rs.hasMore(); rs.next()) {
            cs.init(0, columns);
            for (; cs.hasMore(); cs.next()) {
                put(rs.value(), cs.value(), x.get(rs.index(), cs.index()));
            }
        }

        return this;
    }
mikiobraun commented 4 years ago

Odd, let me look into this.