kaira.modulations.BaseModulator

Inheritance diagram of BaseModulator

Inheritance diagram for BaseModulator

class kaira.modulations.BaseModulator(bits_per_symbol: int | None = None, *args, **kwargs)[source]

Bases: Module, ABC

Abstract base class for all modulators.

A modulator maps bit sequences to complex symbols according to a specific modulation scheme.

constellation

Complex-valued tensor of constellation points

Methods

__init__

Initialize the modulator.

forward

Modulate bits to symbols.

plot_constellation

Plot the constellation diagram.

reset_state

Reset any stateful components.

Attributes

bits_per_symbol

Number of bits per symbol.

__init__(bits_per_symbol: int | None = None, *args, **kwargs) None[source]

Initialize the modulator.

Parameters:
  • bits_per_symbol – Number of bits to encode in each symbol

  • *args – Variable length argument list.

  • **kwargs – Arbitrary keyword arguments.

property bits_per_symbol: int

Number of bits per symbol.

abstractmethod forward(x: Tensor, *args, **kwargs) Tensor[source]

Modulate bits to symbols.

Parameters:
  • x – Input tensor of bits with shape (…, K*N), where K is bits_per_symbol

  • *args – Variable length argument list.

  • **kwargs – Arbitrary keyword arguments.

Returns:

Modulated symbols with shape (…, N)

plot_constellation(**kwargs)[source]

Plot the constellation diagram.

Parameters:

**kwargs – Additional arguments for plotting

Returns:

Matplotlib figure object

reset_state() None[source]

Reset any stateful components.

For modulators with memory (like differential schemes).