question: public static int countNnz ( String [ ] cols , int pos , int len ) { int lnnz = 0 ; for ( int i = pos ; i < pos + len ; i ++ ) { String col = cols [ i ] ; lnnz += ( ! col . isEmpty ( ) && ! col . equals ( "0" ) && ! col . equals ( "0.0" ) ) ? 1 : 0 ; } return lnnz ; }
target:  Returns the number of non-zero entries but avoids the expensive  string to double parsing. This function is guaranteed to never underestimate.