Function PGABinaryHammingDistance

Function Documentation

int PGABinaryHammingDistance(PGAContext *ctx, PGABinary *s1, PGABinary *s2)

Return the Hamming distance between two strings.

Description

Note that this function is used in PGABinaryGeneDistance() for implementing a generic genetic distance function. It is used in the default setting of the PGA_USERFUNCTION_GEN_DISTANCE user function for the binary data type.

Example

Return the Hamming distance between bit strings x and y.

PGAContext *ctx;
PGABinary *x, *y;
int d;

...
d = PGABinaryHammingDistance (ctx, x, y);

Parameters
  • ctx – context variable

  • s1 – the first string to compare

  • s2 – the second string to compare

Returns

The Hamming distance between two strings