1

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 ?

Jay Traband
  • 17,053
  • 1
  • 23
  • 44
Soumya Simanta
  • 11,523
  • 24
  • 106
  • 161
  • Have you looked at Saddle (https://github.com/saddle/saddle) as a replacement for Breeze? – wheaties Apr 22 '14 at 12:51
  • @wheaties, I'm curious to know what you like about Saddle over Breeze. I'd like to know how I can make Breeze better. – dlwh Apr 22 '14 at 19:02

1 Answers1

3

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.

Reactormonk
  • 21,472
  • 14
  • 74
  • 123