Count the number of non-zero elements in R
968209
void countNonZeroInR( int[] parent ) {
        TriangularSolver_DSCC.postorder(parent,n,post,gwork);
        columnCounts.process(A,parent,post,countsR);
        nz_in_R = 0;
        for (int k = 0; k < n; k++) {
            nz_in_R += countsR[k];
        }
        if( nz_in_R < 0)
            throw new RuntimeException("Too many elements. Numerical overflow in R counts");
    }
856162
def count(self, val):
        """"""
        _maxes = self._maxes

        if not _maxes:
            return 0

        key = self._key(val)
        pos = bisect_left(_maxes, key)

        if pos == len(_maxes):
            return 0

        _lists = self._lists
        _keys = self._keys
        idx = bisect_left(_keys[pos], key)
        total = 0
        len_keys = len(_keys)
        len_sublist = len(_keys[pos])

        while True:
            if _keys[pos][idx] != key:
                return total
            if _lists[pos][idx] == val:
                total += 1
            idx += 1
            if idx == len_sublist:
                pos += 1
                if pos == len_keys:
                    return total
                len_sublist = len(_keys[pos])
                idx = 0
266265
private static void countElements(byte[] fp, IAtomContainer mol) {
        int b;
        CountElements ce = new CountElements(mol);

        b = 0;
        if (ce.getCount("H") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 1;
        if (ce.getCount("H") >= 8) fp[b >> 3] |= MASK[b % 8];
        b = 2;
        if (ce.getCount("H") >= 16) fp[b >> 3] |= MASK[b % 8];
        b = 3;
        if (ce.getCount("H") >= 32) fp[b >> 3] |= MASK[b % 8];
        b = 4;
        if (ce.getCount("Li") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 5;
        if (ce.getCount("Li") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 6;
        if (ce.getCount("B") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 7;
        if (ce.getCount("B") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 8;
        if (ce.getCount("B") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 9;
        if (ce.getCount("C") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 10;
        if (ce.getCount("C") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 11;
        if (ce.getCount("C") >= 8) fp[b >> 3] |= MASK[b % 8];
        b = 12;
        if (ce.getCount("C") >= 16) fp[b >> 3] |= MASK[b % 8];
        b = 13;
        if (ce.getCount("C") >= 32) fp[b >> 3] |= MASK[b % 8];
        b = 14;
        if (ce.getCount("N") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 15;
        if (ce.getCount("N") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 16;
        if (ce.getCount("N") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 17;
        if (ce.getCount("N") >= 8) fp[b >> 3] |= MASK[b % 8];
        b = 18;
        if (ce.getCount("O") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 19;
        if (ce.getCount("O") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 20;
        if (ce.getCount("O") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 21;
        if (ce.getCount("O") >= 8) fp[b >> 3] |= MASK[b % 8];
        b = 22;
        if (ce.getCount("O") >= 16) fp[b >> 3] |= MASK[b % 8];
        b = 23;
        if (ce.getCount("F") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 24;
        if (ce.getCount("F") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 25;
        if (ce.getCount("F") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 26;
        if (ce.getCount("Na") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 27;
        if (ce.getCount("Na") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 28;
        if (ce.getCount("Si") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 29;
        if (ce.getCount("Si") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 30;
        if (ce.getCount("P") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 31;
        if (ce.getCount("P") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 32;
        if (ce.getCount("P") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 33;
        if (ce.getCount("S") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 34;
        if (ce.getCount("S") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 35;
        if (ce.getCount("S") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 36;
        if (ce.getCount("S") >= 8) fp[b >> 3] |= MASK[b % 8];
        b = 37;
        if (ce.getCount("Cl") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 38;
        if (ce.getCount("Cl") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 39;
        if (ce.getCount("Cl") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 40;
        if (ce.getCount("Cl") >= 8) fp[b >> 3] |= MASK[b % 8];
        b = 41;
        if (ce.getCount("K") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 42;
        if (ce.getCount("K") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 43;
        if (ce.getCount("Br") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 44;
        if (ce.getCount("Br") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 45;
        if (ce.getCount("Br") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 46;
        if (ce.getCount("I") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 47;
        if (ce.getCount("I") >= 2) fp[b >> 3] |= MASK[b % 8];
        b = 48;
        if (ce.getCount("I") >= 4) fp[b >> 3] |= MASK[b % 8];
        b = 49;
        if (ce.getCount("Be") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 50;
        if (ce.getCount("Mg") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 51;
        if (ce.getCount("Al") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 52;
        if (ce.getCount("Ca") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 53;
        if (ce.getCount("Sc") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 54;
        if (ce.getCount("Ti") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 55;
        if (ce.getCount("V") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 56;
        if (ce.getCount("Cr") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 57;
        if (ce.getCount("Mn") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 58;
        if (ce.getCount("Fe") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 59;
        if (ce.getCount("Co") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 60;
        if (ce.getCount("Ni") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 61;
        if (ce.getCount("Cu") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 62;
        if (ce.getCount("Zn") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 63;
        if (ce.getCount("Ga") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 64;
        if (ce.getCount("Ge") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 65;
        if (ce.getCount("As") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 66;
        if (ce.getCount("Se") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 67;
        if (ce.getCount("Kr") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 68;
        if (ce.getCount("Rb") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 69;
        if (ce.getCount("Sr") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 70;
        if (ce.getCount("Y") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 71;
        if (ce.getCount("Zr") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 72;
        if (ce.getCount("Nb") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 73;
        if (ce.getCount("Mo") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 74;
        if (ce.getCount("Ru") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 75;
        if (ce.getCount("Rh") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 76;
        if (ce.getCount("Pd") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 77;
        if (ce.getCount("Ag") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 78;
        if (ce.getCount("Cd") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 79;
        if (ce.getCount("In") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 80;
        if (ce.getCount("Sn") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 81;
        if (ce.getCount("Sb") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 82;
        if (ce.getCount("Te") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 83;
        if (ce.getCount("Xe") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 84;
        if (ce.getCount("Cs") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 85;
        if (ce.getCount("Ba") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 86;
        if (ce.getCount("Lu") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 87;
        if (ce.getCount("Hf") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 88;
        if (ce.getCount("Ta") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 89;
        if (ce.getCount("W") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 90;
        if (ce.getCount("Re") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 91;
        if (ce.getCount("Os") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 92;
        if (ce.getCount("Ir") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 93;
        if (ce.getCount("Pt") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 94;
        if (ce.getCount("Au") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 95;
        if (ce.getCount("Hg") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 96;
        if (ce.getCount("Tl") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 97;
        if (ce.getCount("Pb") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 98;
        if (ce.getCount("Bi") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 99;
        if (ce.getCount("La") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 100;
        if (ce.getCount("Ce") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 101;
        if (ce.getCount("Pr") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 102;
        if (ce.getCount("Nd") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 103;
        if (ce.getCount("Pm") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 104;
        if (ce.getCount("Sm") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 105;
        if (ce.getCount("Eu") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 106;
        if (ce.getCount("Gd") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 107;
        if (ce.getCount("Tb") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 108;
        if (ce.getCount("Dy") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 109;
        if (ce.getCount("Ho") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 110;
        if (ce.getCount("Er") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 111;
        if (ce.getCount("Tm") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 112;
        if (ce.getCount("Yb") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 113;
        if (ce.getCount("Tc") >= 1) fp[b >> 3] |= MASK[b % 8];
        b = 114;
        if (ce.getCount("U") >= 1) fp[b >> 3] |= MASK[b % 8];
    }
541639
def count(self, table):
        
        if self._operator is None and self._operands is None:
            return self._get_table_len(table)

        return np.count_nonzero(self.mask(table))
273345
def count_values(tokens):
    """"""
    ntoks = 0
    for tok in tokens:
        if tok in ('=', '/', '$', '&'):
            if ntoks > 0 and tok == '=':
                ntoks -= 1
            break
        elif tok in whitespace + ',':
            continue
        else:
            ntoks += 1

    return ntoks
205601
function isRowNonzero (M, i, TOL = 1e-14) {
  const me = M.elements;
  return !(Compare.isZero(me[i], TOL) &&
            Compare.isZero(me[i + 3], TOL) &&
            Compare.isZero(me[i + 6], TOL));
}
818226
private static int countTailoredNodes(long[] nodesArray, int i, int strength) {
        int count = 0;
        for(;;) {
            if(i == 0) { break; }
            long node = nodesArray[i];
            if(strengthFromNode(node) < strength) { break; }
            if(strengthFromNode(node) == strength) {
                if(isTailoredNode(node)) {
                    ++count;
                } else {
                    break;
                }
            }
            i = nextIndexFromNode(node);
        }
        return count;
    }
78438
void countNonZeroInV( int []parent ) {
        int []w = gwork.data;
        findMinElementIndexInRows(leftmost);
        createRowElementLinkedLists(leftmost,w);
        countNonZeroUsingLinkedList(parent,w);
    }
359991
void countNonZeroUsingLinkedList( int parent[] , int ll[] ) {

        Arrays.fill(pinv,0,m,-1);
        nz_in_V = 0;
        m2 = m;

        for (int k = 0; k < n; k++) {
            int i = ll[head+k];           // remove row i from queue k
            nz_in_V++;                    // count V(k,k) as nonzero
            if( i < 0)                    // add a fictitious row since there are no nz elements
                i = m2++;
            pinv[i] = k;                  // associate row i with V(:,k)
            if( --ll[nque+k] <= 0 )
                continue;
            nz_in_V += ll[nque+k];
            int pa;
            if( (pa = parent[k]) != -1 ) { // move all rows to parent of k
                if( ll[nque+pa] == 0)
                    ll[tail+pa] = ll[tail+k];
                ll[next+ll[tail+k]] = ll[head+pa];
                ll[head+pa] = ll[next+i];
                ll[nque+pa] += ll[nque+k];
            }
        }
        for (int i = 0, k = n; i < m; i++) {
            if( pinv[i] < 0 )
                pinv[i] = k++;
        }

        if( nz_in_V < 0)
            throw new RuntimeException("Too many elements. Numerical overflow in V counts");
    }
834934
def _trim_zeros(str_floats, na_rep='NaN'):
    
    trimmed = str_floats

    def _cond(values):
        non_na = [x for x in values if x != na_rep]
        return (len(non_na) > 0 and all([x.endswith('0') for x in non_na]) and
                not(any([('e' in x) or ('E' in x) for x in non_na])))

    while _cond(trimmed):
        trimmed = [x[:-1] if x != na_rep else x for x in trimmed]

    # trim decimal points
    return [x[:-1] if x.endswith('.') and x != na_rep else x for x in trimmed]
354698
def _get_num_similar_rows(self, row, until=None):
        """"""
        return len(list(filter(lambda r: row == r, self.dataset[:until])))
1103197
def _count(expr, pat, flags=0):
    
    return _string_op(expr, Count, output_type=types.int64,
                      _pat=pat, _flags=flags)
1112113
public static int countTrue(BMatrixRMaj A) {
        int total = 0;

        int N = A.getNumElements();

        for (int i = 0; i < N; i++) {
            if( A.data[i] )
                total++;
        }

        return total;
    }
591762
private int countNonNewline(String str, int off, int len) {
    for(int cnt = 0; cnt < len; cnt++) {
      final int pos = off + cnt;
      if(str.charAt(pos) == UNIX_NEWLINE) {
        return cnt;
      }
      if(str.charAt(pos) == CARRIAGE_RETURN) {
        return cnt;
      }
    }
    return len;
  }
1052625
def COUNT(COND, N):
    
    return pd.Series(np.where(COND, 1, 0), index=COND.index).rolling(N).sum()
98879
def nonzero(self):
        
        return [i for i in xrange(self.size()) if self.test(i)]
535751
def num_open_files(self):
        """"""
        return reduce(lambda x, y: x + y, (1 for rlist in self._fdict.values() if len(rlist) > 0), 0)