public static DMatrixSparseCSC convert ( DMatrixSparseTriplet src , DMatrixSparseCSC dst , int hist [ ] ) { if ( dst == null ) dst = new DMatrixSparseCSC ( src . numRows , src . numCols , src . nz_length ) ; else dst . reshape ( src . numRows , src . numCols , src . nz_length ) ; if ( hist == null ) hist = new int [ src . numCols ] ; else if ( hist . length >= src . numCols ) Arrays . fill ( hist , 0 , src . numCols , 0 ) ; else throw new IllegalArgumentException ( "Length of hist must be at least numCols" ) ; // compute the number of elements in each columns for ( int i = 0 ; i < src . nz_length ; i ++ ) { hist [ src . nz_rowcol . data [ i * 2 + 1 ] ] ++ ; } // define col_idx dst . histogramToStructure ( hist ) ; System . arraycopy ( dst . col_idx , 0 , hist , 0 , dst . numCols ) ; // now write the row indexes and the values for ( int i = 0 ; i < src . nz_length ; i ++ ) { int row = src . nz_rowcol . data [ i * 2 ] ; int col = src . nz_rowcol . data [ i * 2 + 1 ] ; double value = src . nz_value . data [ i ] ; int index = hist [ col ] ++ ; dst . nz_rows [ index ] = row ; dst . nz_values [ index ] = value ; } dst . indicesSorted = false ; return dst ; }
Converts SMatrixTriplet_64 into a SMatrixCC_64 .