質問

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 ?

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top