我需要在Python中为pyopencl创建类型为cl.cltypes.uint2
的变量。
现在我这样创建它:
key = np.array([(0x01020304, 0x05060708)], dtype=cl.cltypes.uint2)[0]
它绝对是肮脏的黑客(如何以更干净的方式创建它
这:key = cl.cltypes.uint2((0x01020304, 0x05060708))
由于错误而无法工作:'numpy.dtype' object is not callable
Tags:
快速阅读链接表明它正在生成复合数据类型。如果不加载并运行它,我认为您的示例类似于
并从阵列中取出一条记录:
化合物
dtype
永远不可调用我认为0d“scalar”数组比使用dtype函数创建的对象更好(尽管它们有类似的方法)
对于复合数据类型:
您可以将这样的数组强制转换为
recarray
并获得一个record
对象,但我认为创建这些对象并不容易相关问题 更多 >
编程相关推荐