| |
Algorithm 1: Quantization | |
| |
Input: BSI A, int p | |
Output: BSI S | |
1 | BitSlice penalty = (A[A.size – 2] XOR A.sign); |
2 | for (i = A.size – 2;i >= 0;i − −) do |
3 | penalty = (penalty OR (A[sSize] XOR A.sign)); |
4 | if penalty.count() >= n – p then |
5 | sSize = i; |
6 | break; |
7 | end |
8 | end |
9 | BSI S = new BSI(sSize); |
10 | for (i = 0; i < sSize; i++) do |
11 | S[i] = (A[i] XOR A.sign); |
12 | end |
13 | S.addSlice(penalty); |
14 | return S |