General Utilities
General utilities (optic.utils)
Basic class to be used as a struct of parameters |
|
|
Convert linear value to dB (decibels). |
|
Convert dB (decibels) to a linear value. |
|
Convert dBm to Watts. |
|
Converts a positive integer or an array-like of positive integers to a NumPy array of the specified size containing bits (0 and 1). |
|
Converts a positive integer to a NumPy array of the specified size containing bits (0 and 1). |
|
Computes the dot product of two 1D arrays in a Numba-compatible way. |
|
Converts an input NumPy array of bits (0 and 1) to a decimal integer. |
|
Converts a bit error rate (BER) to a Q factor in dB. |
|
Convert LLRs to bit probabilities using a numerically stable sigmoid. |
- ber2Qfactor(ber)[source]
Converts a bit error rate (BER) to a Q factor in dB.
- bitarray2dec(x_bitarray)[source]
Converts an input NumPy array of bits (0 and 1) to a decimal integer.
- dB2lin(x)[source]
Convert dB (decibels) to a linear value.
- dBm2W(x)[source]
Convert dBm to Watts.
- dec2bitarray(x, bit_width)[source]
Converts a positive integer or an array-like of positive integers to a NumPy array of the specified size containing bits (0 and 1).
- decimal2bitarray(x, bit_width)[source]
Converts a positive integer to a NumPy array of the specified size containing bits (0 and 1). This version is slightly quicker but only works for one integer.
- dotNumba(a, b)[source]
Computes the dot product of two 1D arrays in a Numba-compatible way.
This function is equivalent to
np.dotfor 1D arrays but can be JIT-compiled with Numba for accelerated execution.- Parameters:
a (ndarray of shape (N,)) – First input array (complex-valued).
b (ndarray of shape (N,)) – Second input array (complex-valued).
- Returns:
result – The dot product of a and b, computed as the sum of element-wise products.
- Return type:
Notes
Both input arrays must have the same length.
This function initializes the result as a complex number to support complex-valued operations.
- lin2dB(x)[source]
Convert linear value to dB (decibels).
- llr2bitProb(llr, prec=<class 'numpy.float32'>)[source]
Convert LLRs to bit probabilities using a numerically stable sigmoid.
- Parameters:
llrs (1D numpy array) – Log-likelihood ratios (LLRs) of bits.
- Returns:
probs – Bit probabilities P(bit = 1).
- Return type:
1D numpy array
- class parameters[source]
Basic class to be used as a struct of parameters
- copy()[source]
Returns a deep copy of the parameters object.
This method creates a new instance of the parameters class with the same attributes and values.
- Returns:
A new instance of the parameters class with copied attributes.
- Return type:
- latex_table()[source]
Generates a LaTeX table of the parameters and their values.
- Returns:
A LaTeX table representation of the parameters and their values.
- Return type:
- table()[source]
Generates a Markdown table of the parameters and their values.
- Returns:
A Markdown table representation of the parameters and their values.
- Return type:
- to_engineering_notation(value)[source]
Converts a numerical value to engineering notation with appropriate prefixes.
- view()[source]
Prints the attributes and their values in either standard or scientific notation.