Exemplo n.º 1
0
    def _test_logdetM(self, kappa):
        "Test log(det(M))."

        nx = kappa.rows()
        self.assertRaises(RuntimeError,
                          lambda msg:
                          isle.logdetM(isle.HubbardFermiMatrixDia(kappa, 1, 1), isle.CDVector(nx), isle.Species.PARTICLE),
                          msg="logdetM must throw a RuntimeError when called with mu != 0. If this bug has been fixed, update the unit test!")

        for nt, mu, sigmaKappa, species, rep in itertools.product((4, 8, 32),
                                                                  [0],
                                                                  (-1, 1),
                                                                  (isle.Species.PARTICLE, isle.Species.HOLE),
                                                                  range(N_REP)):
            hfm = isle.HubbardFermiMatrixDia(kappa/nt, mu/nt, sigmaKappa)
            phi = _randomPhi(nx*nt)

            plain = isle.logdet(isle.Matrix(hfm.M(phi, species)))
            viaLU = isle.logdetM(hfm, phi, species)

            self.assertAlmostEqual(plain, viaLU, places=10,
                                   msg="Failed check log(det(M)) in repetition {}".format(rep)\
                                   + "for nt={}, mu={}, sigmaKappa={}, species={}:".format(nt, mu, sigmaKappa, species)\
                                   + "\nplain = {}".format(plain) \
                                   + "\nviaLU = {}".format(viaLU))
Exemplo n.º 2
0
    def _test_logdetQ(self, kappa):
        "Test log(det(Q))."

        nx = kappa.rows()
        for nt, mu, sigmaKappa, rep in itertools.product((4, 8, 32), [0],
                                                         (-1, 1), range(N_REP)):
            hfm = isle.HubbardFermiMatrixDia(kappa/nt, mu/nt, sigmaKappa)
            phi = _randomPhi(nx*nt)

            plain = isle.logdet(isle.Matrix(hfm.Q(phi)))
            viaLU = isle.logdetQ(hfm, phi)

            self.assertAlmostEqual(plain, viaLU, places=10,
                                   msg="Failed check log(det(Q)) in repetition {}".format(rep)\
                                   + "for nt={}, mu={}, sigmaKappa={}:".format(nt, mu, sigmaKappa)\
                                   + "\nplain = {}".format(plain) \
                                   + "\nviaLU = {}".format(viaLU))
Exemplo n.º 3
0
    def _test_logdetM(self, HFM, kappa):
        "Test log(det(M))."

        nx = kappa.rows()
        for nt, beta, mu, sigmaKappa in product((2, 4, 8, 32),
                                                (3, 6),
                                                [0, 0.1, 0.5, 1.0, 2.0],
                                                (-1, 1)):
            hfm = HFM(kappa * beta / nt, mu * beta / nt, sigmaKappa)
            for species, (real, imag), rep in product((isle.Species.PARTICLE, isle.Species.HOLE),
                                                      ((True, False), (False, True), (True, True)),
                                                      range(N_REP)):
                phi = _randomPhi(nx * nt, real=real, imag=imag)
                plain = isle.logdet(isle.Matrix(hfm.M(phi, species)))
                viaLU = isle.logdetM(hfm, phi, species)
                self.assertAlmostEqual(plain, viaLU, places=5,
                                       msg="Failed check log(det(M)) in repetition {}".format(rep)
                                           + "\nfor nt={}, beta={}, mu={}, sigmaKappa={}, species={}, real={}, imag={}"
                                       .format(nt, beta, mu, sigmaKappa, species, real, imag)
                                           + "\n  plain = {}".format(plain)
                                           + "\n  viaLU = {}".format(viaLU))