returns a WireVector sum of rem_bits multiplies (in one clock cycle)
    note: this method requires a lot of area because of the indexing in the else statement
331745
def _one_cycle_mult(areg, breg, rem_bits, sum_sf=0, curr_bit=0):
    
    if rem_bits == 0:
        return sum_sf
    else:
        a_curr_val = areg[curr_bit].sign_extended(len(breg))
        if curr_bit == 0:  # if no shift
            return(_one_cycle_mult(areg, breg, rem_bits-1,  # areg, breg, rem_bits
                                   sum_sf + (a_curr_val & breg),  # sum_sf
                                   curr_bit+1))  # curr_bit
        else:
            return _one_cycle_mult(
                areg, breg, rem_bits-1,  # areg, breg, rem_bits
                sum_sf + (a_curr_val &
                          pyrtl.concat(breg, pyrtl.Const(0, curr_bit))),  # sum_sf
                curr_bit+1  # curr_bit
            )
1192724
def _get_1f_sum_scans(self,d,freq):
        
        
        # combine scans: values with same frequency 
        unique_freq = np.unique(freq)
        
        sum_scans = [[] for i in range(len(d))]
        
        for f in unique_freq: 
            tag = freq==f
            for i in range(len(d)):
                sum_scans[i].append(np.sum(d[i][tag]))
            
        return (np.array(unique_freq),np.array(sum_scans))
336273
def _twos_comp_conditional(orig_wire, sign_bit, bw=None):
    """"""
    if bw is None:
        bw = len(orig_wire)
    new_wire = pyrtl.WireVector(bw)
    with pyrtl.conditional_assignment:
        with sign_bit:
            new_wire |= ~orig_wire + 1
        with pyrtl.otherwise:
            new_wire |= orig_wire
    return new_wire
888311
public static double[] cumsum (double[] vector) {
        // Initialize the return value:
        final double[] retval = new double[vector.length];

        // Iterate and cumulate:
        retval[0] = vector[0];
        for (int i = 1; i < retval.length; i++) {
            retval[i] = vector[i] + retval[i - 1];
        }

        // Done, return:
        return retval;
    }
879603
public static double sumOfSquares(NumberVector v) {
    final int dim = v.getDimensionality();
    double sum = 0;
    for(int d = 0; d < dim; d++) {
      double x = v.doubleValue(d);
      sum += x * x;
    }
    return sum;
  }
53801
def unitvec(vec):
    
    if scipy.sparse.issparse(vec): # convert scipy.sparse to standard numpy array
        vec = vec.tocsr()
        veclen = numpy.sqrt(numpy.sum(vec.data ** 2))
        if veclen > 0.0:
            return vec / veclen
        else:
            return vec

    if isinstance(vec, numpy.ndarray):
        vec = numpy.asarray(vec, dtype=float)
        veclen = numpy.linalg.norm(vec)
        if veclen > 0.0:
            return vec / veclen
        else:
            return vec
945239
def sum(self, axis=None, keepdims=False):
        
        return self.numpy().sum(axis=axis, keepdims=keepdims)
851574
def update_sums(self, r, i, j, data1, data2, sum1, sum2, N=None, centers_sum=None):
        
        # the summation values for this (r,i,j)
        sum1_ij, sum2_ij = compute_sum_values(i, j, data1, data2)

        # digitize
        digr = self.digitize(r, i, j, data1, data2)

        if len(digr) == 3 and isinstance(digr[1], dict):
            dig, paircoords, weights = digr
        elif len(digr) == 2 and isinstance(digr[1], dict):
            dig, paircoords = digr
            weights = None
        else:
            dig = digr
            paircoords = None
            weights = None

        # sum 1
        def add_one_channel(sum1c, sum1_ijc):
            if numpy.isscalar(sum1_ijc) or sum1_ijc.ndim == 1:
                sum1c.flat[:] += utils.bincount(dig, sum1_ijc, minlength=sum1c.size)
            else:
                for d in range(sum1c.shape[0]):
                    sum1c[d].flat[:] += utils.bincount(dig, sum1_ijc[...,d], minlength=sum1c[d].size)

        if self.channels:
            if weights is None:
                raise RuntimeError("`digitize` of multi channel paircount did not return a weight array for the channels")

            sum1_ij = weights * sum1_ij
            # sum1_ij[ichannel, dig, dim]
            for ichannel in range(len(self.channels)):
                add_one_channel(sum1[ichannel], sum1_ij[ichannel])
        else:
            # sum1_ij[dig, dim]
            add_one_channel(sum1, sum1_ij)

        # sum 2, if both data are not points
        if not numpy.isscalar(sum2):
            sum2.flat[:] += utils.bincount(dig, sum2_ij, minlength=sum2.size)

        if N is not None:
            if not paircoords:
                raise RuntimeError("Bin center is requested but not returned by digitize")
            # update the mean coords
            self._update_mean_coords(dig, N, centers_sum, **paircoords)
528426
public LongIntSortedVector getSum(LongIntVector other) {
        LongIntSortedVector sum = new LongIntSortedVector(this);
        sum.add(other);
        return sum;
    }
78715
def one_hot(cls, n, l):
        
        v = [0.0] * l
        v[n] = 1.0
        return Vector(v)
938642
def _sum_cycles_from_tokens(self, tokens: List[str]) -> int:
        """"""
        return sum((int(self._nonnumber_pattern.sub('', t)) for t in tokens))
389684
private int readCorner2(int numRows, int numColumns) {
    int currentByte = 0;
    if (readModule(numRows - 3, 0, numRows, numColumns)) {
      currentByte |= 1;
    }
    currentByte <<= 1;
    if (readModule(numRows - 2, 0, numRows, numColumns)) {
      currentByte |= 1;
    }
    currentByte <<= 1;
    if (readModule(numRows - 1, 0, numRows, numColumns)) {
      currentByte |= 1;
    }
    currentByte <<= 1;
    if (readModule(0, numColumns - 4, numRows, numColumns)) {
      currentByte |= 1;
    }
    currentByte <<= 1;
    if (readModule(0, numColumns - 3, numRows, numColumns)) {
      currentByte |= 1;
    }
    currentByte <<= 1;
    if (readModule(0, numColumns - 2, numRows, numColumns)) {
      currentByte |= 1;
    }
    currentByte <<= 1;
    if (readModule(0, numColumns - 1, numRows, numColumns)) {
      currentByte |= 1;
    }
    currentByte <<= 1;
    if (readModule(1, numColumns - 1, numRows, numColumns)) {
      currentByte |= 1;
    }
    return currentByte;
  }
675340
def parallel_multiplier(items):
    
    machines = []
    for data in (xs[0] for xs in items):
        machines.append(max(1, len(get_svcallers(data)), len(dd.get_algorithm_qc(data))))
    return sum(machines)
1353264
def cdim(self):
        """"""
        if self._cdim is None:
            self._cdim = sum((circuit.cdim for circuit in self.operands))
        return self._cdim
286141
def itemsize_bits(self):
        """"""
        if self.dtype is not None:
            return self.dtype.itemsize * 8
        else:
            return sum(x[1] for x in self.format)
543124
def get_databits():
    
    databits = []
    s = pyserial.Serial()
    for name, value in s.getSupportedByteSizes():
        databits.append((value, name,))
    return tuple(databits)
709919
def square_and_sum(a, s):
    
    cmin, cmax = thread_partition_array(a)
    map_noreturn(asqs, [(a, s, cmin[i], cmax[i]) for i in xrange(len(cmax))])
    return a