def test_gesvda_no_uv(self): a = cupy.array(self.a) s = cusolver.gesvda(a, compute_uv=False) expect = numpy.linalg.svd(self.a, compute_uv=False) if self.dtype in (numpy.float32, numpy.complex64): decimal = 5 else: decimal = 10 testing.assert_array_almost_equal(s, expect, decimal=decimal)
def test_gesvda(self): a = cupy.array(self.a) u, s, v = cusolver.gesvda(a) if a.ndim == 2: batch_size = 1 a = a.reshape((1, ) + a.shape) u = u.reshape((1, ) + u.shape) s = s.reshape((1, ) + s.shape) v = v.reshape((1, ) + v.shape) else: batch_size = a.shape[0] for i in range(batch_size): sigma = cupy.diag(s[i]) vh = v[i].T.conjugate() aa = cupy.matmul(cupy.matmul(u[i], sigma), vh) if self.dtype in (numpy.float32, numpy.complex64): decimal = 5 else: decimal = 10 testing.assert_array_almost_equal(aa, a[i], decimal=decimal)