BitVecBestAlignment
Description
Find best overlapping alignment between two bitvectors. Returns the offset that gives the best alignment score.
Parameters
| Name | Direction | Description |
|---|---|---|
bv1 |
in | First bitvector (reference) |
bv2 |
in | Second bitvector (query) |
Usage example (from documentation)
u64 offset = BitVecBestAlignment(&reference, &query);Success
Returns the offset in bv1 at which bv2 produces the highest alignment score. Neither operand is modified.
Failure
Returns SIZE_MAX when either operand is empty or no candidate alignment yields a positive score. The bitvectors are not modified.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
BitVec.c:1682:
}
u64 BitVecBestAlignment(BitVec *bv1, BitVec *bv2) {
ValidateBitVec(bv1);
ValidateBitVec(bv2);- In
Math.c:648:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecBestAlignment basic functionality\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Math.c:668:
BitVecPush(&bv2, false);
u64 best_pos = BitVecBestAlignment(&bv1, &bv2);
result = result && (best_pos == 0 || best_pos == 4);- In
Math.c:681:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecBestAlignment edge cases\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Math.c:688:
// Test empty bitvectors
u64 best_pos = BitVecBestAlignment(&bv1, &bv2);
result = result && (best_pos == 0);- In
Math.c:696:
BitVecPush(&bv2, false);
best_pos = BitVecBestAlignment(&bv1, &bv2);
result = result && (best_pos == 0);- In
Math.c:729:
double entropy1 = BitVecEntropy(&bv1);
int align_score = BitVecAlignmentScore(&bv1, &bv2, 1, -1);
u64 best_align = BitVecBestAlignment(&bv1, &bv2);
// Test edit distance with smaller vectors (expensive operation)
- In
Math.c:941:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecBestAlignment(NULL, bv2) - should fatal\n");
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);- In
Math.c:944:
BitVec bv2 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv2, true);
BitVecBestAlignment(NULL, &bv2);
BitVecDeinit(&bv2);
DefaultAllocatorDeinit(&alloc);- In
Math.c:953:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecBestAlignment(bv1, NULL) - should fatal\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);- In
Math.c:956:
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&bv1, true);
BitVecBestAlignment(&bv1, NULL);
BitVecDeinit(&bv1);
DefaultAllocatorDeinit(&alloc);- In
Math.c:1355:
DefaultAllocator alloc = DefaultAllocatorInit();
WriteFmt("Testing BitVecBestAlignment all-mismatch best offset == 3\n");
BitVec bv1 = BitVecInit(ALLOCATOR_OF(&alloc));- In
Math.c:1371:
BitVecPush(&bv2, true);
u64 best_offset = BitVecBestAlignment(&bv1, &bv2);
result = result && (best_offset == 3);- In
Math.c:1478:
push_bits(&bv2, "11");
bool result = (BitVecBestAlignment(&bv1, &bv2) == 2);
BitVecDeinit(&bv1);- In
Math.c:1499:
push_bits(&bv2, "000");
bool result = (BitVecBestAlignment(&bv1, &bv2) == 1);
BitVecDeinit(&bv1);- In
Math.c:1518:
push_bits(&bv2, "10");
bool result = (BitVecBestAlignment(&bv1, &bv2) == 0);
BitVecDeinit(&bv1);- In
Math.c:1539:
push_bits(&bv2, "11");
bool result = (BitVecBestAlignment(&bv1, &bv2) == 2);
BitVecDeinit(&bv1);- In
Math.c:1559:
push_bits(&bv2, "11");
bool result = (BitVecBestAlignment(&bv1, &bv2) == 2);
BitVecDeinit(&bv1);
Last updated on