Binary matrix vector multiplication

前端 未结 2 1236
囚心锁ツ
囚心锁ツ 2021-01-05 11:03

I want to multiply a 8x8 binary matrix represented as a unsigned 64 bit integer by a 8 bit vector represented by a unsigned char. However, due to some other issues

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-05 11:22

    You ONLY HAVE 256 vectors! Use lookup tables to generate the right bitmasks, then your logic will be something like

    output_bit_n = bool (matrix [n] & lookup [vector])
    

    In other words, your lookup table can transpose an 8-bit value into the 64-bit world.

    You can efficiently pack this into the result with rotate-with-carry instructions if the compiler isn't smart enough to optimise (value<<=1)|=result.

提交回复
热议问题