Three tricks :
- instead of
17 x , use (10 + 8 -1)x ; then - instead of
10 x , the shift point; then - instead of
8 x , shift bits.
eg:
17 * [3,5,1] = 7 * [3,5,1,0] + [0,3,5,1] = [3,5,1,0]<<3 - [3,5,1,0] + [0,3,5,1]
These are all very quick operations that you can perform on elements:
A[i] = A[i]<<3 - A[i] + A[i+1];
source share