def test_hyperbolic_coupling(self):
     k = coupling.HyperbolicTangent()
     self.assertEqual(k.a, 1)
     self.assertEqual(k.b, 1)
     self.assertEqual(k.midpoint, 0)
     self.assertEqual(k.sigma, 1)
     self._apply_coupling(k)
 def test_hyperbolic_coupling(self):
     k = coupling.HyperbolicTangent()
     assert k.a == 1
     assert k.b == 1
     assert k.midpoint == 0
     assert k.sigma == 1
     self._apply_coupling(k)
Esempio n. 3
0
    def test_tanh(self):
        py_cf = py_coupling.HyperbolicTangent()
        cu_cf = cu_tanh_cfe_pre(py_cf.a[0], py_cf.b[0], py_cf.midpoint[0], py_cf.sigma[0])
        out = numpy.zeros((self.n_thread,), 'f')
        xj, xi = numpy.random.rand(2, self.n_thread).astype('f')

        @self.jit_and_run(out, xi, xj)
        def kernel(out, xi, xj):
            t = cuda.blockDim.x * cuda.blockIdx.x + cuda.threadIdx.x
            out[t] = cu_cf(xi[t], xj[t])

        numpy.testing.assert_allclose(out, py_cf.pre(xi, xj))