首页 > 其他 > 详细

numpy自定义ufunc

时间:2019-08-06 15:10:54      阅读:171      评论:0      收藏:0      [点我收藏+]
def foo(i):
    #transform int to binary
    return binary
    
full_sample_arr = np.arange(2**24).reshape(-1,1)
int_to_binary_ufunc1 = np.frompyfunc(int_to_binary_24,1,1)
y2 = int_to_binary_ufunc1(full_sample_arr)

#经np.frompyfunc之后,将单元素自变量i经复杂运算foo后返回j

#对于庞大的数组计算,该方式比单元素迭代速度快的多的多  

numpy自定义ufunc

原文:https://www.cnblogs.com/alilliam/p/11308882.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!