是否有一个升压(或其他常见的lib)中键入与字符串键矩阵? [英] Is there a Boost (or other common lib) type for matrices with string keys?

查看:108
本文介绍了是否有一个升压(或其他常见的lib)中键入与字符串键矩阵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个密集的矩阵,其中指数对应的基因。而基因标识常常整数,它们是不连续的整数。他们可能是字符串代替了。

I have a dense matrix where the indices correspond to genes. While gene identifiers are often integers, they are not contiguous integers. They could be strings instead, too.

我想我可以使用某种形式的整数键的提振稀疏矩阵,而且如果是连续那就没有关系。或将本依然占据着空间很大,尤其是一些基因有九个数字标识符?

I suppose I could use a boost sparse matrix of some sort with integer keys, and it wouldn't matter if they're contiguous. Or would this still occupy a great deal of space, particularly if some genes have identifiers that are nine digits?

此外,我担心的是松散的存储是不恰当的,因为这是一个全用,所有的矩阵(会有每每一个细胞的距离,并且所提供的基因存在)。

Further, I am concerned that sparse storage is not appropriate, since this is an all-by-all matrix (there will be a distance in each and every cell, provided the gene exists).

我不大可能需要执行任何矩阵运算(例如,矩阵乘法)。我将需要拉出来载体基质(片)的。

I'm unlikely to need to perform any matrix operations (e.g., matrix multiplication). I will need to pull vectors out of the matrix (slices).

这似乎是矩阵的最佳类型将由升压unordered_map(hash map中)被键入,或者甚至只是一个STL的地图。

It seems like the best type of matrix would be keyed by a Boost unordered_map (a hash map), or perhaps even simply an STL map.

我是不是在看这个错误的方式?我真的需要推出自己的?我以为我看到了这样一类在什么地方。

Am I looking at this the wrong way? Do I really need to roll my own? I thought I saw such a class somewhere before.

谢谢!

推荐答案

如果您不需要矩阵运算,你并不需要一个矩阵。具有字符串键2D地图可以用进行映射<地图和LT;字符串>方式> 纯C ++或相应使用哈希映射与Boost

If you don't need matrix operations, you don't need a matrix. A 2D map with string keys can be done with map<map<string> > in plain C++, or using a hash map accordingly from Boost.

这篇关于是否有一个升压(或其他常见的lib)中键入与字符串键矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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