예제 #1
0
    def test_pow(self):
        assert cobj._pow((0.0,2.0),(0.0,0.0)) == (1.0,0.0)
        assert cobj._pow((0.0,0.0),(2.0,0.0)) == (0.0,0.0)
        rr, ir = cobj._pow((0.0,1.0),(2.0,0.0))
        assert abs(-1.0 - rr) < EPS
        assert abs(0.0 - ir) < EPS

        assert cobj._powu((0.0,2.0),0) == (1.0,0.0)
        assert cobj._powu((0.0,0.0),2) == (0.0,0.0)
        assert cobj._powu((0.0,1.0),2) == (-1.0,0.0)
        assert cobj._powi((0.0,2.0),0) == (1.0,0.0)
        assert cobj._powi((0.0,0.0),2) == (0.0,0.0)
        assert cobj._powi((0.0,1.0),2) == (-1.0,0.0)
        c = cobj.W_ComplexObject(0.0,1.0)
        p = cobj.W_ComplexObject(2.0,0.0)
        r = cobj.pow__Complex_Complex_ANY(self.space,c,p,self.space.wrap(None))
        assert r.realval == -1.0
        assert r.imagval == 0.0
예제 #2
0
    def test_pow(self):
        assert cobj._pow((0.0,2.0),(0.0,0.0)) == (1.0,0.0)
        assert cobj._pow((0.0,0.0),(2.0,0.0)) == (0.0,0.0)
        rr, ir = cobj._pow((0.0,1.0),(2.0,0.0))
        assert abs(-1.0 - rr) < EPS
        assert abs(0.0 - ir) < EPS

        assert cobj._powu((0.0,2.0),0) == (1.0,0.0)
        assert cobj._powu((0.0,0.0),2) == (0.0,0.0)
        assert cobj._powu((0.0,1.0),2) == (-1.0,0.0)
        assert cobj._powi((0.0,2.0),0) == (1.0,0.0)
        assert cobj._powi((0.0,0.0),2) == (0.0,0.0)
        assert cobj._powi((0.0,1.0),2) == (-1.0,0.0)
        c = cobj.W_ComplexObject(0.0,1.0)
        p = cobj.W_ComplexObject(2.0,0.0)
        r = cobj.pow__Complex_Complex_ANY(self.space,c,p,self.space.wrap(None))
        assert r.realval == -1.0
        assert r.imagval == 0.0
예제 #3
0
        def _powu((r1, i1), n):
            w_res = W_ComplexObject(r1, i1).pow_positive_int(n)
            return w_res.realval, w_res.imagval
        assert _powu((0.0,2.0),0) == (1.0,0.0)
        assert _powu((0.0,0.0),2) == (0.0,0.0)
        assert _powu((0.0,1.0),2) == (-1.0,0.0)

        def _powi((r1, i1), n):
            w_res = W_ComplexObject(r1, i1).pow_small_int(n)
            return w_res.realval, w_res.imagval
        assert _powi((0.0,2.0),0) == (1.0,0.0)
        assert _powi((0.0,0.0),2) == (0.0,0.0)
        assert _powi((0.0,1.0),2) == (-1.0,0.0)
        c = W_ComplexObject(0.0,1.0)
        p = W_ComplexObject(2.0,0.0)
        r = pow__Complex_Complex_ANY(self.space,c,p,self.space.wrap(None))
        assert r.realval == -1.0
        assert r.imagval == 0.0


class AppTestAppComplexTest:
    spaceconfig = {"usemodules": ["binascii", "rctime"]}

    def w_check_div(self, x, y):
        """Compute complex z=x*y, and check that z/x==y and z/y==x."""
        z = x * y
        if x != 0:
            q = z / x
            assert self.close(q, y)
            q = z.__div__(x)
            assert self.close(q, y)
예제 #4
0
            return w_res.realval, w_res.imagval

        assert _powu((0.0, 2.0), 0) == (1.0, 0.0)
        assert _powu((0.0, 0.0), 2) == (0.0, 0.0)
        assert _powu((0.0, 1.0), 2) == (-1.0, 0.0)

        def _powi((r1, i1), n):
            w_res = W_ComplexObject(r1, i1).pow_small_int(n)
            return w_res.realval, w_res.imagval

        assert _powi((0.0, 2.0), 0) == (1.0, 0.0)
        assert _powi((0.0, 0.0), 2) == (0.0, 0.0)
        assert _powi((0.0, 1.0), 2) == (-1.0, 0.0)
        c = W_ComplexObject(0.0, 1.0)
        p = W_ComplexObject(2.0, 0.0)
        r = pow__Complex_Complex_ANY(self.space, c, p, self.space.wrap(None))
        assert r.realval == -1.0
        assert r.imagval == 0.0


class AppTestAppComplexTest:
    def w_check_div(self, x, y):
        """Compute complex z=x*y, and check that z/x==y and z/y==x."""
        z = x * y
        if x != 0:
            q = z / x
            assert self.close(q, y)
            q = z.__div__(x)
            assert self.close(q, y)
            q = z.__truediv__(x)
            assert self.close(q, y)