English 中文(简体)
2. 步行距离2轨
原标题:Fast hamming distance between 2 bitset
  • 时间:2011-10-21 15:47:06
  •  标签:
  • c++

I m 书写一个软件,主要依靠(1) 进入单一轨道和(2) 在2轨A和B之间(即A和B之间不同的轨道数目)进行哈姆断距离计算。 轨道面积相当大,在10K和1M轨道之间,而且有一席之地。 由于不可能在编纂时知道比照大小,即使用<条码>查询器和带;bool >,但计划很快迁移到<条码>。

以下是我的问题:

(1) 任何关于哪一个实施时间最快的想法?

(2) 为了计算哈姆林的距离,宽松的方法是超越单一轨道,计算两个轨道之间的差别。 但我的感觉是,靠tes而不是借方进行 lo,执行R = byXOR byteB,并在一张有255个条目的表格中看到“当地”距离与R有关。 另一种解决办法是储存255×255矩阵,直接使用,而不用靠 by和 by之间的距离。 因此,我的问题是: 如何从<条码>中执行这一条的任何想法:病媒与带;bool >或增强:动力-bitset? 换言之,你是否知道有办法接触tes体阵列,还是必须从头条上重新编码一切?

最佳回答

(1) Probably vector<char> (or even vector<int>), but that wastes at least 7/8 space on typical hardware. You don t need to unpack the bits if you use a byte or more to store them. Which of vector<bool> or dynamic_bitset is faster, I don t know. That might depend on the C++ implementation.

(2) <代码>boost::dynamic_bitset has operator^<>/code> and a count member, which they can jointly can be used to compute the Hamming long in a likely brief,beit-wasting way. 也可通过to_block_range>;使用该软件,你需要实施一个Hamming远距离计算器,作为OutputIterator

问题回答

如果你从头开始就制定法典,那么,你在从每一条轨道起的某个时间用一个字。 XOR的费用应当非常低,然后使用popcount中的具体执行部分,或者使用你能够找到的最快的计票(可能或不一定涉及256次入读)。

[Edit: see as if this could applicable to boost:dynamic_bitset:to_block_range, with the Block selected as or int or long. 我可以立即研究如何将其用于重复两个轨道,但首先使用外线或将其中一个轨道复制到一个>/code>阵列。 如果你把方案控制留给你,那么你就能够收取一些复印费。 阅读对于这项任务来说相当复杂,当然还有自己的间接费用,复制数据可能比使用<条码>代号<>/代码>和<条码>(<>>)。]

我知道,这将降临这里,但这里是:你能够从病媒使用和喷洒器(0)中获取实际数据。 那么,你可以利用玩忽职守,意思是,把你的指点推到一个 point点或像那个大点,做上述算术,并在某个时候把点推到一个字面。 这样做只会因为你知道,借方是连续包装的,而且会很脆弱(例如,如果改变病媒,可以转移记忆点)。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?