dthuerck / mapmap_cpu

A high-performance general-purpose MRF MAP solver, heavily exploiting SIMD instructions.
BSD 3-Clause "New" or "Revised" License
102 stars 51 forks source link

Setting Pairwise costs table from a std::vector fails #40

Closed lukac closed 1 year ago

lukac commented 1 year ago

When trying to set pairwise costs table from a std::vector as opposed to an array, the call fails. The problem is on this line: https://github.com/dthuerck/mapmap_cpu/blob/master/mapmap/source/cost_instances/pairwise_table.impl.h#L100

With the very last l_a, the expression (li_a + 1) * len_b indexes beyond the end of the vector, and taking a pointer to that is an illegal operation.

A fix would be either passing iterators instead of pointers to std::copy (i.e. packed_table.begin()+(li_a * len_b)) or taking the data pointer of the vector and then using pointer arithmetic on that (i.e. packed_table.data()+(li_a * len_b)).

dthuerck commented 1 year ago

Thanks! Commit is on its way, should be fixed in a sec.