How to start with empty SparseMatrix and add rows

32 views
Skip to first unread message

cogmission1

unread,
Jan 19, 2016, 1:39:44 PM1/19/16
to la4j
the code:

public Matrix insertRow(int i, Vector row) {

        if (i >= rows || i < 0) {

            throw new IndexOutOfBoundsException("Illegal row number, must be 0.." + (rows - 1));

        }


        Matrix result = blankOfShape(rows + 1, columns);


        for (int ii = 0; ii < i; ii++) {

            result.setRow(ii, getRow(ii));

        }


        result.setRow(i, row);


        for (int ii = i; ii < rows; ii++) {

            result.setRow(ii + 1, getRow(ii));

        }


        return result;

    }


Doesn't allow you to start with an empty matrix and add rows to it. I won't every know the size of my matrix upon creation!? :-)


Thanks,

David

Vladimir Kostyukov

unread,
Jan 19, 2016, 9:36:58 PM1/19/16
to cogmission1, la4j
Hello, David,

Do you mind filing a Github issue with a reproducer?
--
Thanks,
Vladimir Kostyukov
Reply all
Reply to author
Forward
0 new messages