Write test for det
@@ -92,6 +92,43 @@ class TestMatrixRank(unittest.TestCase):
return xp.array(y)
+@unittest.skipUnless(
+ cuda.cusolver_enabled, 'Only cusolver in CUDA 8.0 is supported')
+@testing.gpu
+class TestDet(unittest.TestCase):
+
+ _multiprocess_can_split_ = True
+
+ @testing.for_float_dtypes(no_float16=True)
+ @testing.numpy_cupy_allclose(rtol=1e-3, atol=1e-4)
+ def test_det(self, xp, dtype):
+ a = testing.shaped_arange((2, 2), xp, dtype) + 1
+ return xp.linalg.det(a)
+
+ @testing.for_float_dtypes(no_float16=True)
+ @testing.numpy_cupy_allclose(rtol=1e-3, atol=1e-4)
+ def test_slogdet_3(self, xp, dtype):
+ a = testing.shaped_arange((2, 2, 2), xp, dtype) + 1
+ return xp.linalg.det(a)
+
+ @testing.for_float_dtypes(no_float16=True)
+ @testing.numpy_cupy_allclose(rtol=1e-3, atol=1e-4)
+ def test_slogdet_4(self, xp, dtype):
+ a = testing.shaped_arange((2, 2, 2, 2), xp, dtype) + 1
+ return xp.linalg.det(a)
+
+ @testing.for_float_dtypes(no_float16=True)
+ @testing.numpy_cupy_allclose(rtol=1e-3, atol=1e-4)
+ def test_slogdet_fail(self, xp, dtype):
+ a = xp.zeros((3, 3), dtype)
+ return xp.linalg.det(a)
+
+ @testing.numpy_cupy_raises(numpy.linalg.LinAlgError)
+ def test_slogdet_one_dim(self, xp, dtype):
+ a = testing.shaped_arange((2,), xp, dtype)
+ xp.linalg.det(a)
+
+
@unittest.skipUnless(
cuda.cusolver_enabled, 'Only cusolver in CUDA 8.0 is supported')
@testing.gpu
