digitrevorder
Rearranges the digits of the input data in reverse order.
| Library |
|
Arguments
Input arguments
# r is the base of the number system
+
an integer
Details
The base of the number system, specified as an integer in the range [2, 36].
Output arguments
# i — indexes of rearranged digits
+
vector | the matrix
Details
The indexes of the rearranged digits returned as a vector or matrix. Indexing starts with 1.
Examples
The numbers are in reverse order in the number system with base 3
Details
Let’s set an input vector of 9 values. We get a vector containing the numbers in reverse order in the base number system. 3 and their indexes.
import EngeeDSP.Functions: digitrevorder
x = (0:8)'
y, i = digitrevorder(x,3)
println("x\ty\tj")
println("__________________")
for j in 1:length(x)
println(x[j],"\t",y[j],"\t", i[j])
end
x y j
__________________
0 0 1
1 3 4
2 6 7
3 1 2
4 4 5
5 7 8
6 2 3
7 5 6
8 8 9
Additional Info
The numbers are in reverse order
Details
This table shows the numbers from 0 before 15, their corresponding numbers and numbers in reverse order in the base number system 4. The corresponding bits in the base number system are also shown. 2 and the corresponding indexes.
| Linear index | Base numbers 4 |
The numbers are in reverse order | Indexes of numbers in reverse order | Base bits 2 |
The bits are in reverse order | The bit indexes are in reverse order |
|---|---|---|---|---|---|---|
0 |
00 |
00 |
0 |
0000 |
0000 |
0 |
1 |
01 |
10 |
4 |
0001 |
1000 |
8 |
2 |
02 |
20 |
8 |
0010 |
0100 |
4 |
3 |
03 |
30 |
12 |
0011 |
1100 |
12 |
4 |
10 |
01 |
1 |
0100 |
0010 |
2 |
5 |
11 |
11 |
5 |
0101 |
1010 |
10 |
6 |
12 |
21 |
9 |
0110 |
0110 |
6 |
7 |
13 |
31 |
13 |
0111 |
1110 |
14 |
8 |
20 |
02 |
2 |
1000 |
0001 |
1 |
9 |
21 |
12 |
6 |
1001 |
1001 |
9 |
10 |
22 |
22 |
10 |
1010 |
0101 |
5 |
11 |
23 |
32 |
14 |
1011 |
1101 |
13 |
12 |
30 |
03 |
3 |
1100 |
0011 |
3 |
13 |
31 |
13 |
7 |
1101 |
1011 |
11 |
14 |
32 |
23 |
11 |
1110 |
0111 |
7 |
15 |
33 |
33 |
15 |
1111 |
1111 |
15 |