in reply to unpacking 6-bit values

vec's no good because it only does powers of 2-bits.

Just out of interest (and to try to get my head around how it works) I thought I'd see if I could come up with a vec solution although I didn't expect it to challenge in the speed stakes. By combining 4-bit and 2-bit vecs with 2- or 4-bit shifts you can obtain your 6-bit values. As expected, it trails the field. (I didn't test the C solutions as I don't have Inline installed).

sub johngg { map { my $offsetVec4 = $_ * 6; my $offsetVec2 = $_ * 12; my @vals = ( ( ( vec( $_[0], $offsetVec4 + 1, 4 ) << 2 ) + vec( $_[0], $offsetVec2 + 1, 2 ) ), ( ( vec( $_[0], $offsetVec2, 2 ) << 4 ) + vec( $_[0], $offsetVec4 + 3, 4 ) ), ( ( vec( $_[0], $offsetVec4 + 2, 4 ) << 2 ) + vec( $_[0], $offsetVec2 + 11, 2 ) ), ( ( vec( $_[0], $offsetVec2 + 10, 2 ) << 4 ) + vec( $_[0], $offsetVec4 + 4, 4 ) ), ); } 0 .. 7; }
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 2 +3 24 25 26 27 28 29 30 31 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 2 +3 24 25 26 27 28 29 30 31 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 2 +3 24 25 26 27 28 29 30 31 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 2 +3 24 25 26 27 28 29 30 31 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 2 +3 24 25 26 27 28 29 30 31 Rate johngg buk jethro jmcnamara salva johngg 22191/s -- -3% -29% -42% -51% buk 22974/s 4% -- -27% -39% -49% jethro 31438/s 42% 37% -- -17% -30% jmcnamara 37959/s 71% 65% 21% -- -16% salva 45081/s 103% 96% 43% 19% --

I hope this is of interest.

Cheers,

JohnGG