Question

I've a DenseMatrix

1  2  3  0   0   0   0    0    0    
0  0  0  11  22  33  0    0    0    
0  0  0  0   0   0   111  222  333 

I want to remove the first row and then a last row with all 0s

0  0  0  11  22  33  0    0    0    
0  0  0  0   0   0   111  222  333 
0  0  0  0   0   0   0    0    0   

How do I achieve this in Breeze ?

Was it helpful?

Solution

First, gather the rows you still want:

val subset = matrix(::, 2 to 3)

then add the zeroes:

val newMatrix = DenseMatrix.horzcat(subset, DenseMatrix.zeros[Double](1,9))

I might have mixed up rows and columns in the last line.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top