Scrambler
__init__()
Scramble the vectors \(v_t^{(0)}\) and \(v_t^{(1)}\), returning the vectors \(X[n]\) and \(Y[n]\) scrambled. The scrambling process is given by the expression below.
Where
- \(X[n]\) and \(Y[n]\): Scrambled output vectors.
- \(A\), \(B\) and \(C\): Combination of bits of the input vectors \(v_t^{(0)}\) and \(v_t^{(1)}\).
- \(n\): Index of the bit to be scrambled.
The scrambling process is illustrated by the block diagram below.
Examples:
>>> import argos3
>>> import numpy as np
>>>
>>> vt0 = np.random.randint(0, 2, 15)
>>> vt1 = np.random.randint(0, 2, 15)
>>>
>>> idx_vt0 = [f"X{i+1}" for i in range(len(vt0))]
>>> idx_vt1 = [f"Y{i+1}" for i in range(len(vt1))]
>>>
>>> scrambler = argos3.Scrambler()
>>> Xn, Yn = scrambler.scramble(vt0, vt1)
>>> idx_Xn, idx_Yn = scrambler.scramble(idx_vt0, idx_vt1)
>>>
>>> print(vt0)
[0 1 1 1 1 0 0 0 1 0 0 0 0 0 1]
>>> print(vt1)
[1 0 0 1 1 1 0 1 0 1 0 0 0 1 1]
>>> print(idx_vt0)
['X1', 'X2', 'X3', 'X4', 'X5', 'X6', 'X7', 'X8', 'X9', 'X10', 'X11', 'X12', 'X13', 'X14', 'X15']
>>> print(idx_vt1)
['Y1', 'Y2', 'Y3', 'Y4', 'Y5', 'Y6', 'Y7', 'Y8', 'Y9', 'Y10', 'Y11', 'Y12', 'Y13', 'Y14', 'Y15']
>>>
>>> print(idx_Xn)
['Y1', 'X2', 'Y2', 'Y4', 'X5', 'Y5', 'Y7', 'X8', 'Y8', 'Y10', 'X11', 'Y11', 'Y13', 'X14', 'Y14']
>>> print(idx_Yn)
['X1', 'X3', 'Y3', 'X4', 'X6', 'Y6', 'X7', 'X9', 'Y9', 'X10', 'X12', 'Y12', 'X13', 'X15', 'Y15']
>>>
>>> vt0_prime, vt1_prime = scrambler.descramble(Xn,Yn)
>>> idx_vt0_prime, idx_vt1_prime = scrambler.descramble(idx_Xn, idx_Yn)
>>>
>>> print(idx_vt0_prime)
['X1', 'X2', 'X3', 'X4', 'X5', 'X6', 'X7', 'X8', 'X9', 'X10', 'X11', 'X12', 'X13', 'X14', 'X15']
>>> print(idx_vt1_prime)
['Y1', 'Y2', 'Y3', 'Y4', 'Y5', 'Y6', 'Y7', 'Y8', 'Y9', 'Y10', 'Y11', 'Y12', 'Y13', 'Y14', 'Y15']
- Bitstream Plot Example:
AS3-SP-516-274-CNES (seção 3.1.4.5)
scramble(vt0, vt1)
Receive the vectors \(v_t^{(0)}\) and \(v_t^{(1)}\) as input and return the vectors \(X[n]\) and \(Y[n]\) scrambled.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vt0
|
ndarray
|
Input vector \(v_t^{(0)}\). |
required |
vt1
|
ndarray
|
Input vector \(v_t^{(1)}\). |
required |
Returns:
Name | Type | Description |
---|---|---|
X_scrambled |
ndarray
|
Scrambled vector \(X[n]\). |
Y_scrambled |
ndarray
|
Scrambled vector \(Y[n]\). |
Raises:
Type | Description |
---|---|
AssertionError
|
If the vectors X and Y do not have the same length. |
unscramble(X_prime, Y_prime)
Receive the vectors \(X'[n]\) and \(Y'[n]\) scrambled and return the vectors \(v_t^{(0)'}\) and \(v_t^{(1)'}\) restored.
Where
- \(v_t^{(0)'}\) and \(v_t^{(1)'}\): Output vectors restored.
- \(A\), \(B\) and \(C\): Combination of bits of the input vectors \(X'[n]\) and \(Y'[n]\) scrambled.
- \(n\): Index of the bit to be scrambled.
The descrambling process is illustrated by the block diagram below.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X_prime
|
ndarray
|
Vector \(X'_{n}\) scrambled. |
required |
Y_prime
|
ndarray
|
Vector \(Y'_{n}\) scrambled. |
required |
Returns:
Name | Type | Description |
---|---|---|
vt0_prime |
ndarray
|
Vector \(v_t^{(0)}\) restored. |
vt1_prime |
ndarray
|
Vector \(v_t^{(1)}\) restored. |
Raises:
Type | Description |
---|---|
AssertionError
|
If the vectors X and Y do not have the same length. |