代表稀疏张量的数据结构? [英] Data structure for representing sparse tensor?

查看:123
本文介绍了代表稀疏张量的数据结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是合适的数据结构来表示C ++中的稀疏tesnor? 我想到的第一个选项是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)

使用boost::unordered_map实施此运算符有多容易?有更合适的数据结构吗?

How easy would it be to implement this operator with a boost::unordered_map? Is there a more appropriate data structure?

推荐答案

有可用的张量库,例如:

There are tensor libraries available, like:

http://www.codeproject.com/KB/recipes/tensor.aspx

http://cadadr.org/fm/package/ftensor.html

这些有什么问题吗?这样一来,在使用地图的过程中,您将获得更多的张量操作.

Any issue with those? You'd get more tensor operations that way over using a map.

这篇关于代表稀疏张量的数据结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆