The examples rely on this definition:
permu_arr_0<13> const q {4, 8, 6, 5, 12, 3, 7, 11, 1, 2, 10, 0, 9};
|
void transpose_position (int const i, int const j, int const k = 1);
- i is the first position of one swap region;
- j is the first position of the other swap region;
- k is how many elements are in each swap region.
The two regions may not overlap.
|
void transpose_value (int const i, int const j, int const k = 1);
- i is the lowest value of one swap range;
- j is the lowest value of the other swap range;
- k is how many elements are in each swap range.
The two ranges may not overlap.
|
Given these statements:
permu_arr_0<13> p {q};
p.transpose_position (7, 2, 3);
what happens is:
- the elements at positions 7 and 2 are exchanged;
- the elements at positions 8 and 3 are exchanged;
- the elements at positions 9 and 4 are exchanged.
table 1 — zero-based transpose_position
|
---|
position:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
| original:
| 4 | 8 | 6 | 5 | 12 | 3 | 7 | 11 | 1 | 2 | 10 | 0 | 9
| (7, 2, 3):
| 4 | 8 | 11 | 1 | 2 | 3 | 7 | 6 | 5 | 12 | 10 | 0 | 9
|
| Given these statements:
permu_arr_0<13> p {q};
p.transpose_value (7, 2, 3);
what happens is:
- elements 7 and 2 are exchanged;
- elements 8 and 3 are exchanged;
- elements 9 and 4 are exchanged.
table 2 — zero-based transpose_value
|
---|
position:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
| original:
| 4 | 8 | 6 | 5 | 12 | 3 | 7 | 11 | 1 | 2 | 10 | 0 | 9
| (7, 2, 3):
| 9 | 3 | 6 | 5 | 12 | 8 | 2 | 11 | 1 | 7 | 10 | 0 | 4
|
|
↑ equivalent ↓ | ↑ equivalent ↓
|
Given these statements:
permu_arr_1<13> p {q};
p.transpose_position (8, 3, 3);
the result is:
- the elements at positions 8 and 3 are exchanged;
- the elements at positions 9 and 4 are exchanged;
- the elements at positions 10 and 5 are exchanged.
table 3 — one-based transpose_position
|
---|
position:
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13
| original:
| 5 | 9 | 7 | 6 | 13 | 4 | 8 | 12 | 2 | 3 | 11 | 1 | 10
| (8, 3, 3):
| 5 | 9 | 12 | 2 | 3 | 4 | 8 | 7 | 6 | 13 | 11 | 1 | 10
|
| Given these statements:
permu_arr_1<13> p {q};
p.transpose_value (8, 3, 3);
the result is:
- elements 8 and 3 are exchanged;
- elements 9 and 4 are exchanged;
- elements 10 and 5 are exchanged.
table 4 — one-based transpose_value
|
---|
position:
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13
| original:
| 5 | 9 | 7 | 6 | 13 | 4 | 8 | 12 | 2 | 3 | 11 | 1 | 10
| (8, 3, 3):
| 10 | 4 | 7 | 6 | 13 | 9 | 3 | 12 | 2 | 8 | 11 | 1 | 5
|
|
permu_vec_0 and permu_vec_1 work the same way.
|