hamming-distance

calculate hamming distance and weight in sqlite

你离开我真会死。 提交于 2019-12-08 03:29:56
问题 Is there a good way to calculate hamming distance and weight in sqlite? It supports bit-wise operators but I want to order results based on hamming weight, and there is no support for bitcount in sqlite. To be more elaborate, let's say I have those rows: 1011 1000 1100 0011 and given the 1st row (1011) I would like to get as a result last row (0011) which has the most 1s if you AND them. In my case the numbers will be about 650 digits long, and I have about 3500 rows. I've found this solution

Checking the error detection capabilities of CRC polynomials

老子叫甜甜 提交于 2019-12-07 07:27:15
问题 I tried to find out how to calculate the error detection capabilities of arbitrary CRC polynomials. I know that there are various error detection capabilities that may (or may not) apply to an arbitrary polynomial: Detection of a single bit error: All CRCs can do this since this only requires a CRC width >= 1. Detection of burst errors: All CRCs can detect burst errors up to a size that equals their width. Detection of odd numbers of bit errors: CRC with polynomials with an even number of

Optimal way to cluster set of strings with hamming distance [duplicate]

隐身守侯 提交于 2019-12-06 16:46:29
问题 This question already has answers here : Fast computation of pairs with least hamming distance (1 answer) Finding Minimum hamming distance of a set of strings in python (4 answers) Closed 4 years ago . I have a database with n strings (n > 1 million), each string has 100 chars, each char is either a , b , c or d . I would like to find the closest strings for each one , closest defines as having the smallest hamming distance . I would like to find the k-nearest strings for each one (k < 5).

The hunt for the fastest Hamming Distance C implementation [duplicate]

懵懂的女人 提交于 2019-12-06 06:09:48
问题 This question already has answers here : Bit Operation For Finding String Difference (6 answers) Closed 6 years ago . I want to find how many different characters two strings of equal length have. I have found that xoring algorithms are considered to be the fastest, but they return distance expressed in bits. I want the results expressed in characters. Suppose that "pet" and "pit" have distance 1 expressed in characters but 'e' and 'i' might have two different bits, so xoring returns 2. The

Optimized CUDA matrix hamming distance

旧巷老猫 提交于 2019-12-06 06:04:43
问题 Is anyone aware of an optimized CUDA kernel for computing a GEMM style hamming distance between two matrices of dimension A x N and N x B? The problem is nearly identical to GEMM, but instead computes the sum( a_n != b_n ) for each vector {1 ... N}, instead of multiplying and summing each vector element. I wanted to verify before writing my own, since this problem is relatively common, but I haven't had success in finding code for it yet. Suggestions for code to modify would be excellent as

Checking the error detection capabilities of CRC polynomials

孤者浪人 提交于 2019-12-05 14:32:46
I tried to find out how to calculate the error detection capabilities of arbitrary CRC polynomials. I know that there are various error detection capabilities that may (or may not) apply to an arbitrary polynomial: Detection of a single bit error: All CRCs can do this since this only requires a CRC width >= 1. Detection of burst errors: All CRCs can detect burst errors up to a size that equals their width. Detection of odd numbers of bit errors: CRC with polynomials with an even number of terms (which means an even number of 1-bits in the full binary polynomial) can do this. Detection of

Hamming distance between two binary strings not working

强颜欢笑 提交于 2019-12-04 23:18:47
问题 I found an interesting algorithm to calculate hamming distance on this site: def hamming2(x,y): """Calculate the Hamming distance between two bit strings""" assert len(x) == len(y) count,z = 0,x^y while z: count += 1 z &= z-1 # magic! return count The point is that this algorithm only works on bit strings and I'm trying to compare two strings that are binary but they are in string format, like '100010' '101000' How can I make them work with this algorithm? 回答1: Implement it: def hamming2(s1,

Optimal way to cluster set of strings with hamming distance [duplicate]

无人久伴 提交于 2019-12-04 22:25:52
This question already has an answer here: Fast computation of pairs with least hamming distance 1 answer Finding Minimum hamming distance of a set of strings in python 4 answers I have a database with n strings (n > 1 million), each string has 100 chars, each char is either a , b , c or d . I would like to find the closest strings for each one , closest defines as having the smallest hamming distance . I would like to find the k-nearest strings for each one (k < 5). Example N = 5 i1 = aacbdbbb i2 = abcbdbbb i3 = bbcadabd i4 = bbcadabb HammingDistance(i1,i2) = 1 HammingDistance(i1,i3) = 5

Calculate distance between two descriptors

你离开我真会死。 提交于 2019-12-04 21:36:17
I'm trying to calculate the distance (Euclidean or hamming) between two descriptors already calculated. The problem is I don't want to use a matcher, I just want to calculate the distance between two descriptors. I'm using OpenCV 2.4.9 and i have mine descriptors stored in a Mat type: Mat descriptors1; Mat descriptors2; and now i just want to calculate the distance (preferably the Hamming distance since I'm using binary descriptors) between row1 of descriptors1 and row1 of descriptors2 (for example). I have tried to use bitwise_xor() function but then I got not an effective way of doing the

How to find the closest pairs (Hamming Distance) of a string of binary bins in Ruby without O^2 issues?

岁酱吖の 提交于 2019-12-04 11:37:10
问题 I've got a MongoDB with about 1 million documents in it. These documents all have a string that represents a 256 bit bin of 1s and 0s, like: 0110101010101010110101010101 Ideally, I'd like to query for near binary matches. This means, if the two documents have the following numbers. Yes, this is Hamming Distance. This is NOT currently supported in Mongo. So, I'm forced to do it in the application layer. So, given this, I am trying to find a way to avoid having to do individual Hamming distance