Exemplo n.º 1
0
 def _test_float_arith(self, op):
     arith_c = CompiledFunction(arith, {
         "op": base_types.VInt(),
         "a": base_types.VFloat(), "b": base_types.VFloat()})
     for a in _test_range():
         for b in _test_range():
             self.assertEqual(arith_c(op, a/2, b/2), arith(op, a/2, b/2))
Exemplo n.º 2
0
 def _test_frac_arith_float(self, op, rev):
     f = frac_arith_float_rev if rev else frac_arith_float
     f_c = CompiledFunction(f, {
         "op": base_types.VInt(),
         "a": base_types.VInt(), "b": base_types.VInt(),
         "x": base_types.VFloat()})
     for a in _test_range():
         for b in _test_range():
             for x in _test_range():
                 self.assertAlmostEqual(
                     f_c(op, a, b, x/2),
                     f(op, a, b, x/2))
Exemplo n.º 3
0
 def _visit_expr_Num(self, node):
     n = node.n
     if isinstance(n, int):
         if abs(n) < 2**31:
             r = base_types.VInt()
         else:
             r = base_types.VInt(64)
     elif isinstance(n, float):
         r = base_types.VFloat()
     else:
         raise NotImplementedError
     if self.builder is not None:
         r.set_const_value(self.builder, n)
     return r