Return the sum of elements of the Pauli algebra
498204
def pauli_sum(*elements: Pauli) -> Pauli:
    """"""
    terms = []

    key = itemgetter(0)
    for term, grp in groupby(heapq.merge(*elements, key=key), key=key):
        coeff = sum(g[1] for g in grp)
        if not isclose(coeff, 0.0):
            terms.append((term, coeff))

    return Pauli(tuple(terms))
604922
def chi_a(mass1, mass2, spin1z, spin2z):
    
    return (spin2z * mass2 - spin1z * mass1) / (mass2 + mass1)
664654
def prefixSum(self, i):
        
        sum = 0
        while i > 0:
            sum += self.s[i]
            i -= (i & -i)
        return sum
76587
def _one_body_mapping(a_i, a_j, threshold=0.000001):
        
        pauli_list = []
        for alpha in range(2):
            for beta in range(2):
                pauli_prod = Pauli.sgn_prod(a_i[alpha], a_j[beta])
                coeff = 1.0/4 * pauli_prod[1] * np.power(-1j, alpha) * np.power(1j, beta)
                pauli_term = [coeff, pauli_prod[0]]
                if np.absolute(pauli_term[0]) > threshold:
                    pauli_list.append(pauli_term)
        return Operator(paulis=pauli_list)
1268436
def get_electron_number(self, charge=0):
        
        atomic_number = constants.elements['atomic_number'].to_dict()
        return sum([atomic_number[atom] for atom in self['atom']]) - charge
1200602
def sum(self):
        
        return LazyOpResult(
            grizzly_impl.aggr(
                self.expr,
                "+",
                0,
                self.weld_type
            ),
            self.weld_type,
            0
        )
977953
def sumvalues(self, q=0):
        
        if q == 0:
            return self._totalf
        else:
            return -np.partition(-self._freq_list, q)[:q].sum()
295096
def expectation(self, operator: Union[PauliTerm, PauliSum]):
        
        if not isinstance(operator, PauliSum):
            operator = PauliSum([operator])

        return sum(_term_expectation(self.wf, term, n_qubits=self.n_qubits) for term in operator)
692987
def dot(self, w):
        """"""

        return sum([x * y for x, y in zip(self, w)])
618966
def sum(self):
        
        return self._constructor(self.values.sum(axis=self.baseaxes, keepdims=True))
867158
public double sum() {
	double res = 0.0;
	for (int i = 0; i < len; i++) {
	    res += vect[i];
	}
	return res;	
    }
676261
def inter_spin_hamiltonian(self, u_int, J_coup):
        """"""
        J_coup *= u_int
        h_int  = (u_int - 2*J_coup)/2.*self.oper['sumSz2']
        h_int += J_coup*self.oper['sumSz-sp2']
        h_int -= J_coup/2.*self.oper['sumSz-or2']
        h_int -= J_coup*self.oper['Sfliphop']

        return h_int
13506
def collective_dr_squared( self ):
        
        return sum( np.square( sum( [ atom.dr for atom in self.atoms ] ) ) )
196556
public static double elementSum( DMatrixD1 mat ) {
        double total = 0;

        int size = mat.getNumElements();

        for( int i = 0; i < size; i++ ) {
            total += mat.get(i);
        }

        return total;
    }
945239
def sum(self, axis=None, keepdims=False):
        
        return self.numpy().sum(axis=axis, keepdims=keepdims)
858086
def sumai(array):
    
    n = ctypes.c_int(len(array))
    array = stypes.toIntVector(array)
    return libspice.sumai_c(array, n)
941518
def sum(self):
        
        return self.mapPartitions(lambda x: [sum(x)]).fold(0, operator.add)