Is there any convenient and efficient way to remove rows (or columns) from SparseMatrix
in ojAlgo? I was trying to retrieve RowView
from my matrix and then copy rows that should remain element by element to new matrix but this is not very efficient method.
Asked
Active
Viewed 175 times
1

Piotr Baniukiewicz
- 11
- 2
1 Answers
0
Doing the same thing but using the ElementView2D
obtained from the nonzeros()
method would be much more efficient.

apete
- 1,250
- 1
- 10
- 16
-
Thanks, I'll try this. Is it possible to select rows to be copied by using e.g. ElementSupplier or RowsSupplier interfaces and then supplyTo method with destination object as parameter? – Piotr Baniukiewicz Jun 04 '18 at 14:57
-
The problem with RowView and ColumnView is that they essentially assume the underlying data structure is dense (efficient random access). RowsSupplier or ColumnsSupplier could be alternatives for you. Do you need to be able to remove both rows and columns? – apete Jun 06 '18 at 07:56
-
I need to remove both but not simultaneously. I think the problem is that my sparse matrix has 9M non-zero elements. Even creating by looping over them and using `set` from `SparseStore` takes around 5 minutes. – Piotr Baniukiewicz Jun 06 '18 at 11:09
-
ojAlgo currently doesn't have a mechanism to do efficient bulk inserts to sparse matrices (that could be useful when doing a copy). A PR to do that would be appreciated. Do you really need to copy that matrix? Would like to point out that creating a custom matrix implementation in ojAlgo is really simple: https://github.com/optimatika/ojAlgo/wiki/Create-Custom-MatrixStore Create your own that does precisely what you need, and optimise the operations that matter to you. – apete Jun 07 '18 at 12:59