Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot insert new column as last column. #309

Open
aintHuman opened this issue Dec 16, 2019 · 0 comments
Open

Cannot insert new column as last column. #309

aintHuman opened this issue Dec 16, 2019 · 0 comments

Comments

@aintHuman
Copy link

aintHuman commented Dec 16, 2019

Dealing with sparse matrix, I want to insert a column, as a new last column, so if the initial matrix was m x n, then the new matrix should be m x (n+1)

If my sparse matrix occupies the variable mat, then I am trying this as follows:

mat = (SparseMatrix)mat.insertColumn(mat.columns(), Vector.fromArray(new_column_array_data));

However, this throws an error java.lang.IndexOutOfBoundsException: Illegal row number,

Now if I perform the same operation, but 1 column back, inserting between the current 2nd last and current last column,

mat = (SparseMatrix)mat.insertColumn(mat.columns()-1, Vector.fromArray(new_column_array_data));

Then the new data is indeed inserted, however, it is not in the correct position per my requirements, I need the new column inserted as the final column.

So is this a bug or a feature?

In order to get around the above, at the moment, I am having to insert (duplicate) the current last column, at the 2nd last column, then insert my desired column, and then finally remove the last column. Requiring 3 operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant