-
sdr.kasami_code(length: int, index: int | tuple[int, int] =
0
, poly: PolyLike | None =None
, output: 'binary' ='binary'
) ndarray[Any, dtype[int64]] -
sdr.kasami_code(length: int, index: int | tuple[int, int] =
0
, poly: PolyLike | None =None
, output: 'field' ='binary'
) FieldArray -
sdr.kasami_code(length: int, index: int | tuple[int, int] =
0
, poly: PolyLike | None =None
, output: 'bipolar' ='binary'
) ndarray[Any, dtype[float64]] Returns the Kasami code/sequence of length \(N\).
- Parameters:¶
- length: int¶
The length \(N = 2^n - 1\) of the Kasami code/sequence. The degree \(n\) must be even.
- index: int | tuple[int, int] =
0
¶ The index of the Kasami code.
int
: The index \(m\) in \([-1, 2^{n/2} - 1)\) from the Kasami code small set. There are \(2^{n/2}\) codes in the small set.tuple[int, int]
: The index \((k, m)\) from the Kasami code large set, with \(k \in [-2, 2^n - 1)\) and \(m \in [-1, 2^{n/2} - 1)\). There are \((2^n + 1) \cdot 2^{n/2}\) codes in the large set.
- poly: PolyLike | None =
None
¶ The primitive polynomial of degree \(n\) over \(\mathrm{GF}(2)\). The default is
None
, which uses the default primitive polynomial of degree \(n\), i.e.galois.primitive_poly(2, n)
.- output: 'binary' =
'binary'
¶ - output: 'field' =
'binary'
- output: 'bipolar' =
'binary'
The output format of the Kasami code/sequence.
"binary"
(default): The Kasami code with binary values of 0 and 1."field"
: The Kasami code as a Galois field array over \(\mathrm{GF}(2)\)."bipolar"
: The Kasami sequence with bipolar values of 1 and -1.
- Returns:¶
The Kasami code/sequence of length \(N\).
References¶
Examples¶
Create a Kasami code and sequence of length 15.
In [1]: sdr.kasami_code(15, 1) Out[1]: array([1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0]) In [2]: sdr.kasami_code(15, 1, output="bipolar") Out[2]: array([-1., -1., -1., 1., 1., -1., 1., 1., 1., 1., 1., -1., -1., 1., 1.]) In [3]: sdr.kasami_code(15, 1, output="field") Out[3]: GF([1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0], order=2)
Create several Kasami codes of length 63 from the small set.
In [4]: seq1 = sdr.kasami_code(63, 0, output="bipolar"); \ ...: seq2 = sdr.kasami_code(63, 1, output="bipolar"); \ ...: seq3 = sdr.kasami_code(63, 2, output="bipolar"); ...: In [5]: plt.figure(); \ ...: sdr.plot.time_domain(seq1 + 3, label="Index 0"); \ ...: sdr.plot.time_domain(seq2 + 0, label="Index 1"); \ ...: sdr.plot.time_domain(seq3 - 3, label="Index 2") ...:
Examine the autocorrelation of the Kasami sequences.
In [6]: lag = np.arange(-seq1.size + 1, seq1.size); \ ...: acorr12 = np.correlate(seq1, seq1, mode="full"); \ ...: acorr13 = np.correlate(seq2, seq2, mode="full"); \ ...: acorr23 = np.correlate(seq3, seq3, mode="full"); ...: In [7]: plt.figure(); \ ...: sdr.plot.time_domain(lag, np.abs(acorr12), label="0"); \ ...: sdr.plot.time_domain(lag, np.abs(acorr13), label="1"); \ ...: sdr.plot.time_domain(lag, np.abs(acorr23), label="2"); \ ...: plt.xlabel("Lag"); \ ...: plt.title("Autocorrelation of length-63 Kasami sequences"); ...:
Examine the cross correlation of the Kasami sequences.
In [8]: lag = np.arange(-seq1.size + 1, seq1.size); \ ...: xcorr12 = np.correlate(seq1, seq2, mode="full"); \ ...: xcorr13 = np.correlate(seq1, seq3, mode="full"); \ ...: xcorr23 = np.correlate(seq2, seq3, mode="full"); ...: In [9]: plt.figure(); \ ...: sdr.plot.time_domain(lag, np.abs(xcorr12), label="0 and 1"); \ ...: sdr.plot.time_domain(lag, np.abs(xcorr13), label="0 and 2"); \ ...: sdr.plot.time_domain(lag, np.abs(xcorr23), label="1 and 2"); \ ...: plt.xlabel("Lag"); \ ...: plt.title("Cross correlation of length-63 Kasami sequences"); ...: