question: private static void unsafeBinaryScalar ( MatrixBlock m1 , MatrixBlock ret , ScalarOperator op ) throws DMLRuntimeException { if ( m1 . isEmptyBlock ( false ) ) { double val = op . executeScalar ( 0 ) ; if ( val != 0 ) ret . reset ( ret . rlen , ret . clen , val ) ; return ; } if ( ret . sparse ) throw new DMLRuntimeException ( "Unsupported unsafe binary scalar operations over sparse output representation." ) ; if ( m1 . sparse ) { ret . allocateDenseBlock ( ) ; SparseBlock a = m1 . sparseBlock ; double [ ] c = ret . denseBlock ; int m = m1 . rlen ; int n = m1 . clen ; double cval0 = op . executeScalar ( 0 ) ; Arrays . fill ( c , cval0 ) ; int nnz = m * n ; for ( int i = 0 , cix = 0 ; i < m ; i ++ , cix += n ) { if ( ! a . isEmpty ( i ) ) { int apos = a . pos ( i ) ; int alen = a . size ( i ) ; int [ ] aix = a . indexes ( i ) ; double [ ] avals = a . values ( i ) ; for ( int j = apos ; j < apos + alen ; j ++ ) { double val = op . executeScalar ( avals [ j ] ) ; c [ cix + aix [ j ] ] = val ; nnz -= ( val == 0 ) ? 1 : 0 ; } } } ret . nonZeros = nnz ; } else { denseBinaryScalar ( m1 , ret , op ) ; } }
target:  Since this operation is sparse-unsafe, ret should always be passed in dense representation.