@cc_nrt.export('zero_scalar', 'f8(i4)') def zero_scalar(n): arr = np.zeros(n) return arr[-1] if has_blas: # This one also needs BLAS @cc_nrt.export('vector_dot', 'f8(i4)') def vector_dot(n): a = np.linspace(1, n, n) return np.dot(a, a) # This one needs an environment @cc_nrt.export('zeros', 'f8[:](i4)') def zeros(n): return np.zeros(n) # # Legacy API # exportmany(['multf f4(f4,f4)', 'multi i4(i4,i4)'])(mult) # Needs to link to helperlib to due with complex arguments # export('multc c16(c16,c16)')(mult) export('mult f8(f8, f8)')(mult)
#!/usr/bin/env python from numba.pycc import exportmany, export def mult(a, b): return a * b export('multi i4(i4, i4)')(mult) exportmany(['multf f4(f4, f4)', 'mult f8(f8, f8)'])(mult)
# This one clashes with libc random() unless pycc is careful with naming. @cc_helperlib.export('random', 'f8(i4)') def random_impl(seed): if seed != -1: np.random.seed(seed) return np.random.random() # These ones need NRT cc_nrt = CC('pycc_test_nrt') @cc_nrt.export('zero_scalar', 'f8(i4)') def zero_scalar(n): arr = np.zeros(n) return arr[-1] # This one needs an environment @cc_nrt.export('zeros', 'f8[:](i4)') def zeros(n): return np.zeros(n) # # Legacy API # exportmany(['multf f4(f4,f4)', 'multi i4(i4,i4)'])(mult) # Needs to link to helperlib to due with complex arguments # export('multc c16(c16,c16)')(mult) export('mult f8(f8, f8)')(mult)
@cc_nrt.export("zeros", "f8[:](i4)") def zeros(n): return np.zeros(n) # requires list dtor, #issue3535 @cc_nrt.export("np_argsort", "intp[:](float64[:])") def np_argsort(arr): return np.argsort(arr) # # Legacy API # exportmany(["multf f4(f4,f4)", "multi i4(i4,i4)"])(mult) # Needs to link to helperlib to due with complex arguments # export('multc c16(c16,c16)')(mult) export("mult f8(f8, f8)")(mult) @cc_nrt.export("dict_usecase", "intp[:](intp[:])") def dict_usecase(arr): d = typed.Dict() for i in range(arr.size): d[i] = arr[i] out = np.zeros_like(arr) for k, v in d.items(): out[k] = k * v return out