venumML.time_series.Phineus.phineus_FFT

def generate_twiddle_factors(n):

Generates the twiddle factors for the Fast Fourier Transform (FFT) as tuples of real and imaginary parts.

Parameters
  • n (int): Length of the sequence.
Returns
  • list of tuple: Twiddle factors represented as tuples of (real, imaginary) values.
def next_power_of_2(n):

Calculate the next power of 2 greater than or equal to n.

Parameters
  • n (int): The input integer.
Returns
  • int: The smallest power of 2 greater than or equal to n.
def pad_ciphervec(ctx, x, pad_length=None, pad_value=0):

Pads the input encrypted vector to a specified length using a padding value.

Parameters
  • ctx (EncryptionContext): The encryption context used to encrypt padding values.
  • x (np.ndarray): Encrypted input vector.
  • pad_length (int, optional): Desired length of the padded vector.
  • pad_value (int, optional, default=0): Value to use for padding the vector, which will be encrypted.
Returns
  • np.ndarray: Encrypted padded vector.
def hann_window(ctx, x):

Applies a Hann window to the input encrypted signal to reduce spectral leakage.

Parameters
  • ctx (EncryptionContext): The encryption context used to encrypt window values.
  • x (np.ndarray): Encrypted input signal.
Returns
  • np.ndarray: The input signal multiplied by the encrypted Hann window.
def FFT(ctx, x_unpadded, pad_data=False, window_data=False):

Computes the Fast Fourier Transform (FFT) of an encrypted signal using the 1D Cooley-Tukey algorithm, a recursive implementation of the 1D Cooley-Tukey FFT without using complex numbers.

Parameters
  • ctx (EncryptionContext): The encryption context used to encrypt data and twiddle factors.
  • x_unpadded (np.ndarray): Encrypted input signal.
  • pad_data (bool, optional, default=False): Whether to pad the input data to the next power of 2 for FFT optimisation.
  • window_data (bool, optional, default=False): Whether to apply a Hann window to the input data before the FFT.
Returns
  • list of tuple: The FFT of the input signal as a list of tuples (real, imaginary).
def rfftfreq(n, d=1.0):

Returns the Discrete Fourier Transform sample frequencies for real input signals.

Parameters
  • n (int): Window length.
  • d (float, optional, default=1.0): Sample spacing (inverse of the sampling rate).
Returns
  • np.ndarray: Array of frequencies.