Skip to content

meyer_wavelet

Bases: discrete_wavelet

Meyer wavelet implementation.

This wavelet has a compactly supported frequency response.

Source code in tinybig/koala/signal_processing/wavelet.py
class meyer_wavelet(discrete_wavelet):
    """
    Meyer wavelet implementation.

    This wavelet has a compactly supported frequency response.
    """
    def __init__(self, name: str = 'meyer_wavelet', *args, **kwargs):
        """
        Initialize the Meyer wavelet.

        Parameters
        ----------
        name : str, optional
            Name of the wavelet. Default is 'meyer_wavelet'.
        *args, **kwargs
            Additional parameters.
        """
        super().__init__(name=name, *args, **kwargs)

    def psi(self, tau: torch.Tensor):
        """
        Define the Meyer wavelet function.

        Parameters
        ----------
        tau : torch.Tensor
            Transformed input values.

        Returns
        -------
        torch.Tensor
            Wavelet values for the input.
        """
        result = torch.zeros_like(tau)

        zero_mask = (tau == 0)
        result[zero_mask] = 2.0/3.0 + 4.0/(3.0 * torch.pi)

        nonzero_mask = ~zero_mask
        t_nonzero = tau[nonzero_mask]
        result[nonzero_mask] = (
            (torch.sin((2.0 * torch.pi / 3.0) * t_nonzero) +
             4.0/3.0 * t_nonzero * torch.cos((4.0 * torch.pi / 3.0) * t_nonzero)) /
            (torch.pi * t_nonzero - (16.0 * torch.pi / 9.0) * t_nonzero ** 3)
        )
        return result

__init__(name='meyer_wavelet', *args, **kwargs)

Initialize the Meyer wavelet.

Parameters:

Name Type Description Default
name str

Name of the wavelet. Default is 'meyer_wavelet'.

'meyer_wavelet'
*args

Additional parameters.

()
**kwargs

Additional parameters.

()
Source code in tinybig/koala/signal_processing/wavelet.py
def __init__(self, name: str = 'meyer_wavelet', *args, **kwargs):
    """
    Initialize the Meyer wavelet.

    Parameters
    ----------
    name : str, optional
        Name of the wavelet. Default is 'meyer_wavelet'.
    *args, **kwargs
        Additional parameters.
    """
    super().__init__(name=name, *args, **kwargs)

psi(tau)

Define the Meyer wavelet function.

Parameters:

Name Type Description Default
tau Tensor

Transformed input values.

required

Returns:

Type Description
Tensor

Wavelet values for the input.

Source code in tinybig/koala/signal_processing/wavelet.py
def psi(self, tau: torch.Tensor):
    """
    Define the Meyer wavelet function.

    Parameters
    ----------
    tau : torch.Tensor
        Transformed input values.

    Returns
    -------
    torch.Tensor
        Wavelet values for the input.
    """
    result = torch.zeros_like(tau)

    zero_mask = (tau == 0)
    result[zero_mask] = 2.0/3.0 + 4.0/(3.0 * torch.pi)

    nonzero_mask = ~zero_mask
    t_nonzero = tau[nonzero_mask]
    result[nonzero_mask] = (
        (torch.sin((2.0 * torch.pi / 3.0) * t_nonzero) +
         4.0/3.0 * t_nonzero * torch.cos((4.0 * torch.pi / 3.0) * t_nonzero)) /
        (torch.pi * t_nonzero - (16.0 * torch.pi / 9.0) * t_nonzero ** 3)
    )
    return result