AMP 的非矩形数据包装器?
我正在尝试 Visual Studio 11 Dev Preview。我有一个问题域,需要使用“锯齿状”数组,即第二维大小不统一的数组数组。我发现的 MSDN 文档仅涉及多维数组,其中每个维度都是固定大小的。有什么方法可以模拟所需的行为吗?
I'm experimenting with the Visual Studio 11 Dev Preview. I've got a problem domain which requires the use of "jagged" arrays, i.e., an array of arrays where the second dimension is not of uniform size. The MSDN documentation I've found only concerns multi-dimensional arrays where each dimension is fixed-size. Is there any way to emulate the behaviour desired?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您有 C++ AMP 提供的平面一维数组,您可以模拟很多东西,包括锯齿状数组。例如,您可以使用一个包含元素存储的数组和包含存储偏移量的第二个数组来构建常见的稀疏矩阵表示。然而,在 C# 和 Java 中,交错数组也意味着“带有指向其他(动态分配)数组的指针的数组”。这不是直接支持的东西,除非您在数组中模拟整个堆,因为 C++ AMP 不支持数组中的指针。你想达到什么目的?
If you have a flat 1d array, which C++ AMP offers, you can emulate a lot of things, including jagged arrays. For example, you could build common sparse-matrix representations with one array containing the storage for elements and a second array containing offsets into the storage. However, in C# and Java jagged arrays are also meant to mean “an array with pointers to other (dynamically allocated) arrays”. That, is not something that will be straight forward to support, unless you're simulating a whole heap inside an array, because C++ AMP doesn't support pointers in arrays. What are you trying to achieve?