Return  a set of constraints that define fermionic ladder operators.

    :param a: The non-Hermitian variables.
    :type a: list of :class:`sympy.physics.quantum.operator.Operator`.
    :returns: a dict of substitutions.
436715
def bosonic_constraints(a):
    
    substitutions = {}
    for i, ai in enumerate(a):
        substitutions[ai * Dagger(ai)] = 1.0 + Dagger(ai) * ai
        for aj in a[i+1:]:
            # substitutions[ai*Dagger(aj)] = -Dagger(ai)*aj
            substitutions[ai*Dagger(aj)] = Dagger(aj)*ai
            substitutions[Dagger(ai)*aj] = aj*Dagger(ai)
            substitutions[ai*aj] = aj*ai
            substitutions[Dagger(ai) * Dagger(aj)] = Dagger(aj) * Dagger(ai)

    return substitutions
493293
def H(self) -> 'Kraus':
        """"""
        operators = [op.H for op in self.operators]
        return Kraus(operators, self.weights)
105074
public static FloatMatrix pinv(FloatMatrix A) {
    return solveLeastSquares(A, FloatMatrix.eye(A.rows));
  }
1345132
def diagonals(self):
        
        left_top_shifts = map(lambda i: (-(i + 1), -(i + 1)), range(min(
            self.left_distance, self.top_distance)))
        left_bottom_shifts = map(lambda i: (-(i + 1), +(i + 1)), range(min(
            self.left_distance, self.bottom_distance)))
        right_top_shifts = map(lambda i: (+(i + 1), -(i + 1)), range(min(
            self.right_distance, self.top_distance)))
        right_bottom_shifts = map(lambda i: (+(i + 1), +(i + 1)), range(min(
            self.right_distance, self.bottom_distance)))
        return set(chain(
            left_top_shifts, left_bottom_shifts,
            right_top_shifts, right_bottom_shifts))
447524
public static ComplexFloatMatrix[] eigenvectors(FloatMatrix A) {
        A.assertSquare();
        // setting up result arrays
        FloatMatrix WR = new FloatMatrix(A.rows);
        FloatMatrix WI = WR.dup();
        FloatMatrix VR = new FloatMatrix(A.rows, A.rows);

        SimpleBlas.geev('N', 'V', A.dup(), WR, WI, dummyFloat, VR);

        // transferring the result
        ComplexFloatMatrix E = new ComplexFloatMatrix(WR, WI);
        ComplexFloatMatrix V = new ComplexFloatMatrix(A.rows, A.rows);
        //System.err.printf("VR = %s\n", VR.toString());
        for (int i = 0; i < A.rows; i++) {
            if (E.get(i).isReal()) {
                V.putColumn(i, new ComplexFloatMatrix(VR.getColumn(i)));
            } else {
                ComplexFloatMatrix v = new ComplexFloatMatrix(VR.getColumn(i), VR.getColumn(i + 1));
                V.putColumn(i, v);
                V.putColumn(i + 1, v.conji());
                i += 1;
            }
        }
        return new ComplexFloatMatrix[]{V, ComplexFloatMatrix.diag(E)};
    }
550875
def chol(A):
    
    A = np.array(A)
    assert A.shape[0] == A.shape[1], "Input matrix must be square"

    L = [[0.0] * len(A) for _ in range(len(A))]
    for i in range(len(A)):
        for j in range(i + 1):
            s = sum(L[i][k] * L[j][k] for k in range(j))
            L[i][j] = (
                (A[i][i] - s) ** 0.5 if (i == j) else (1.0 / L[j][j] * (A[i][j] - s))
            )

    return np.array(L)
508413
def adjoint(self):
        
        return MatrixOperator(self.matrix.conj().T,
                              domain=self.range, range=self.domain,
                              axis=self.axis)
1369305
protected void init(DMatrixRMaj A ) {
        UBV = A;

        m = UBV.numRows;
        n = UBV.numCols;

        min = Math.min(m,n);
        int max = Math.max(m,n);

        if( b.length < max+1 ) {
            b = new double[ max+1 ];
            u = new double[ max+1 ];
        }
        if( gammasU.length < m ) {
            gammasU = new double[ m ];
        }
        if( gammasV.length < n ) {
            gammasV = new double[ n ];
        }
    }
226241
def qn_to_qubo(expr):
    
    try:
        import sympy
    except ImportError:
        raise ImportError("This function requires sympy. Please install it.")
    assert type(expr) == sympy.Add
    to_i = lambda s: int(str(s)[1:])
    max_i = max(map(to_i, expr.free_symbols)) + 1
    qubo = [[0.] * max_i for _ in range(max_i)]
    for arg in expr.args:
        syms = arg.free_symbols
        assert len(syms) <= 2
        if len(syms) == 2:
            assert type(arg) == sympy.Mul
            i, j = list(map(to_i, syms))
            if i > j:
                i, j = j, i
            if i == j:
                if len(arg.args) == 2:
                    qubo[i][i] = float(arg.args[0])
                elif len(arg.args) == 1:
                    qubo[i][i] = 1.0
                else:
                    raise ValueError(f"Too many args! arg.args = {arg.args}")
                continue
            if len(arg.args) == 3:
                qubo[i][j] = float(arg.args[0])
            elif len(arg.args) == 2:
                qubo[i][j]
        if len(syms) == 1:
            if len(arg.args) == 2:
                assert type(arg) == sympy.Mul
                i = to_i(next(iter(syms)))
                qubo[i][i] = float(arg.args[0])
            elif len(arg.args) == 1:
                qubo[i][i] = 1.0
            else:
                raise ValueError(f"Too many args! arg.args = {arg.args}")
    return qubo
169894
def relaxation_operators(p):
    
    k0 = np.array([[1.0, 0.0], [0.0, np.sqrt(1 - p)]])
    k1 = np.array([[0.0, np.sqrt(p)], [0.0, 0.0]])
    return k0, k1
1117186
def pauli_basis(nq=1):
    
    basis = tensor_product_basis(*[
        TomographyBasis(
            gell_mann_basis(2).data[[0, 2, 3, 1]],
            [2],
            [u'𝟙', r'\sigma_x', r'\sigma_y', r'\sigma_z']
        )
    ] * nq)

    basis._name = 'pauli_basis'
    return basis
870470
def AB(self):
        '''
        
        '''
        try:
            return self._AB
        except AttributeError:
            pass
        self._AB = [self.A, self.B]
        return self._AB
1351328
def bb2hw(a:Collection[int])->np.ndarray:
    ""
    return np.array([a[1],a[0],a[3]-a[1],a[2]-a[0]])
64187
def get_implicit_constraints(self,relations):
        ''' '''

        constraints = []
        for relation in [r for r in relations if not r.is_negated()]  :
            const_dict = relation.get_constants()
            for constant in const_dict:
                for position in const_dict[constant]:
                    constraints.append( \
                        relation.get_name() + '.' + self.mapPositionToColumnName(relation,position) + ' = ' + str(constant) \
                    )
        return constraints
53546
def crystalfield(interaction=np.linspace(0, 20, 201), \
                 j_hund=np.linspace(0, 0.35, 71)):
    """"""
    slsp = Spinon(slaves=6, orbitals=3, hopping=[0.5]*6, \
               populations=[1, 1, 1.5, 1.5, 1.5, 1.5])

    zet = []
    for hund_cu in j_hund:
        zet.append(ssplt.solve_loop(slsp, interaction, hund_cu)[0][0])
    np.savez('PRB_83_205112', zeta=zet, u_int=interaction, j_hund=j_hund)
107280
def as_dict(self):
        
        d = {"vasp_version": self.vasp_version,
             "has_vasp_completed": True,
             "nsites": len(self.final_structure)}
        comp = self.final_structure.composition
        d["unit_cell_formula"] = comp.as_dict()
        d["reduced_cell_formula"] = Composition(comp.reduced_formula).as_dict()
        d["pretty_formula"] = comp.reduced_formula
        symbols = [s.split()[1] for s in self.potcar_symbols]
        symbols = [re.split(r"_", s)[0] for s in symbols]
        d["is_hubbard"] = self.is_hubbard
        d["hubbards"] = self.hubbards

        unique_symbols = sorted(list(set(self.atomic_symbols)))
        d["elements"] = unique_symbols
        d["nelements"] = len(unique_symbols)

        d["run_type"] = self.run_type

        vin = {"incar": {k: v for k, v in self.incar.items()},
               "crystal": self.final_structure.as_dict(),
               "kpoints": self.kpoints.as_dict()}
        actual_kpts = [{"abc": list(self.actual_kpoints[i]),
                        "weight": self.actual_kpoints_weights[i]}
                       for i in range(len(self.actual_kpoints))]
        vin["kpoints"]["actual_points"] = actual_kpts
        vin["potcar"] = [s.split(" ")[1] for s in self.potcar_symbols]
        vin["potcar_spec"] = self.potcar_spec
        vin["potcar_type"] = [s.split(" ")[0] for s in self.potcar_symbols]
        vin["parameters"] = {k: v for k, v in self.parameters.items()}
        vin["lattice_rec"] = self.lattice_rec.as_dict()
        d["input"] = vin

        vout = {"crystal": self.final_structure.as_dict(),
                "efermi": self.efermi}

        if self.eigenvalues:
            eigen = defaultdict(dict)
            for spin, values in self.eigenvalues.items():
                for i, v in enumerate(values):
                    eigen[i][str(spin)] = v
            vout["eigenvalues"] = eigen
            (gap, cbm, vbm, is_direct) = self.eigenvalue_band_properties
            vout.update(dict(bandgap=gap, cbm=cbm, vbm=vbm,
                             is_gap_direct=is_direct))

            if self.projected_eigenvalues:
                peigen = []
                for i in range(len(eigen)):
                    peigen.append({})
                for spin, v in self.projected_eigenvalues.items():
                    for kpoint_index, vv in enumerate(v):
                        if str(spin) not in peigen[kpoint_index]:
                            peigen[kpoint_index][str(spin)] = vv
                vout['projected_eigenvalues'] = peigen

        d['output'] = vout
        return jsanitize(d, strict=True)
1215971
public static final Atom unitVector(Atom a) {
		double amount = amount(a) ;

		double[] coords = new double[3];

		coords[0] = a.getX() / amount ;
		coords[1] = a.getY() / amount ;
		coords[2] = a.getZ() / amount ;

		a.setCoords(coords);
		return a;

	}