matrix - Create an new DenseMatrix from an submatrix in Breeze using Scala -


i've densematrix (original). slice remove last column (subset). after want access data in subset. however, subset.data still points data in old densematrix (original). idea i'm missing here , how fix ?

original: breeze.linalg.densematrix[int] =  1    200  3  0     10   201  4  0     111  200  0  100   150  195  0  160   200  190  0  150    scala> val numcols = original.cols numcols: int = 4  scala> val subset = original(::, 0 numcols - 2) subset: breeze.linalg.densematrix[int] =  1    200  3   10   201  4   111  200  0   150  195  0   200  190  0    scala> subset.data res0: array[int] = array(1, 10, 111, 150, 200, 200, 201, 200, 195, 190, 3, 4, 0, 0, 0, 0, 0, 100, 160, 150)  scala> subset.data.size res1: int = 20 

never mind figured out 1 way of doing it.

by using following

scala> subset.todensematrix.data res10: array[int] = array(1, 10, 111, 150, 200, 200, 201, 200, 195, 190, 3, 4, 0, 0, 0)  scala> subset.todensematrix.data.size res11: int = 15 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -