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;
}

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 ; }
returns the number of non - zero entries but avoids the expensive string to double parsing . this function is guaranteed to never underestimate .
