Пример #1
0
 def test_types(self):
     for typ in [(single, single), 
                 (double, double), 
                 (csingle, single),
                 (cdouble, double)]:
         for x in [ [0], [[0]], [[[0]]] ]:
             assert_equal(gula.det(array(x, dtype=typ[0])).dtype, typ[0])
             assert_equal(gula.slogdet(array(x, dtype=typ[0]))[0].dtype, typ[0])
             assert_equal(gula.slogdet(array(x, dtype=typ[0]))[1].dtype, typ[1])
Пример #2
0
    def test_zero(self):
        assert_equal(gula.det(array([[0.0]], dtype=single)), 0.0)
        assert_equal(gula.det(array([[0.0]], dtype=double)), 0.0)
        assert_equal(gula.det(array([[0.0]], dtype=csingle)), 0.0)
        assert_equal(gula.det(array([[0.0]], dtype=cdouble)), 0.0)

        assert_equal(gula.slogdet(array([[0.0]], dtype=single)), (0.0, -inf))
        assert_equal(gula.slogdet(array([[0.0]], dtype=double)), (0.0, -inf))
        assert_equal(gula.slogdet(array([[0.0]], dtype=csingle)), (0.0, -inf))
        assert_equal(gula.slogdet(array([[0.0]], dtype=cdouble)), (0.0, -inf))
Пример #3
0
    def do(self, a, b):
        d = gula.det(a)
        s, ld = gula.slogdet(a)
        assert_almost_equal(s * np.exp(ld), d)

        if np.csingle == a.dtype.type or np.single == a.dtype.type:
            cmp_type=np.csingle
        else:
            cmp_type=np.cdouble

        ev = gula.eigvals(a.astype(cmp_type))
        assert_almost_equal(d.astype(cmp_type),
                            multiply.reduce(ev.astype(cmp_type),
                                            axis=(ev.ndim-1)))
        if s != 0:
            assert_almost_equal(np.abs(s), 1)
        else:
            assert_equal(ld, -inf)