Пример #1
0
    def test_real_single_vector_vector_dot(self):

        na = np.array(self.real_veca, dtype=np.float32)
        nb = np.array(self.real_vecb, dtype=np.float32)
        nc = np.dot(na, nb)
        nd = cn.pdot(na, nb)
        self.assert_(test.scalars_equal(nc, nd, epsilon=0.05))
Пример #2
0
 def test_complex_single_vector_vector_dot(self):
     va = cn.array(self.complex_veca, dtype=cn.complex64)
     vb = cn.array(self.complex_vecb, dtype=cn.complex64)
     vc = va.dot(vb)
     # check we get the same answer as numpy
     na = np.array(self.complex_veca, dtype=np.complex64)
     nb = np.array(self.complex_vecb, dtype=np.complex64)
     nc = np.dot(na, nb)
     self.assert_(test.scalars_equal(vc, nc, epsilon=0.05))
Пример #3
0
 def test_real_double_vector_vector_dot(self):
     va = cn.array(self.real_veca, dtype=cn.float64)
     vb = cn.array(self.real_vecb, dtype=cn.float64)
     vc = va.dot(vb)
     # check we get the same answer as numpy
     na = np.array(self.real_veca, dtype=np.float64)
     nb = np.array(self.real_vecb, dtype=np.float64)
     nc = np.dot(na,nb)
     self.assert_(test.scalars_equal(vc, nc, epsilon=0.0001))
Пример #4
0
 def test_real_single_matrix_product(self):
     A_ = cn.array(self.real_mata, dtype=cn.float32)
     A = np.array(self.real_mata, dtype=np.float32)
     # gpu
     s = A_.product()
     # cpu
     sn = np.product(A)
     # XXX this precision doesn't always return true
     self.assert_(test.scalars_equal(sn, s, 1E-04))
Пример #5
0
 def test_norm_complex_matrix(self):
     A = cn.array(self.complex_mata, dtype=cn.complex64)
     # numpy
     a = np.array(self.complex_mata, dtype=np.complex64)
     self.assert_(test.scalars_equal(lalg.norm(a), A.norm()))
Пример #6
0
 def test_norm_real_matrix(self):
     A = cn.array(self.real_mata, dtype=cn.float32)
     # numpy
     a = np.array(self.real_mata, dtype=np.float32)
     self.assert_(test.scalars_equal(lalg.norm(a), A.norm()))
Пример #7
0
 def test_asum_complex_matrix(self):
     A = cn.array(self.complex_mata, dtype=cn.complex64)
     # numpy
     a = np.array(self.complex_mata, dtype=np.complex64)
     self.assert_(test.scalars_equal(np.sum(np.abs(a)), A.asum()))
Пример #8
0
 def test_asum_real_matrix(self):
     A = cn.array(self.real_mata, dtype=cn.float32)
     # numpy
     a = np.array(self.real_mata, dtype=np.float32)
     self.assert_(test.scalars_equal(np.sum(np.abs(a)), A.asum()))