表示稀疏张量的数据结构?
在 C++ 中表示稀疏张量的合适数据结构是什么? 我想到的第一个选项是 boost::unordered_map ,因为它允许快速设置和检索元素等操作,如下所示:
A(i,j,k,l) = 5
但是,我也希望能够对 a 进行收缩单个索引,这将涉及对其中一个索引进行求和
C(i,j,k,m) = A(i,j,k,l)*B(l,m)
使用 boost::unordered_map
实现此运算符有多容易?有没有更合适的数据结构?
What is an appropriate data structure to represent a sparse tesnor in C++?
The first option that comes to mind is a boost::unordered_map
since it allows operations like fast setting and retrieval of an an element like below:
A(i,j,k,l) = 5
However, I would also like to be able to do contractions over a single index, which would involve summation over one of the indices
C(i,j,k,m) = A(i,j,k,l)*B(l,m)
How easy would it be to implement this operator with a boost::unordered_map
? Is there a more appropriate data structure?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有可用的张量库,例如:
和
这些有什么问题吗?与使用地图相比,您可以获得更多的张量运算。
There are tensor libraries available, like:
and
Any issue with those? You'd get more tensor operations that way over using a map.