Skip to content

nlft_qsp.util

Utility functions.

Functions:

Name Description
next_power_of_two

Returns the smallest power of two that is \(\ge n\).

unitroots

Returns a list containing the \(N\)-th roots of unity.

next_power_of_two(n)

Returns the smallest power of two that is \(\ge n\).

Source code in nlft_qsp/util.py
5
6
7
def next_power_of_two(n):
    r"""Returns the smallest power of two that is $\ge n$."""
    return 1 << (n - 1).bit_length()

unitroots(N: int)

Returns a list containing the \(N\)-th roots of unity.

Source code in nlft_qsp/util.py
def unitroots(N: int):
    r"""Returns a list containing the $N$-th roots of unity."""
    return [np.exp(2j*np.pi*k/N) for k in range(N)]