fft

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2024 License: Apache-2.0 Imports: 10 Imported by: 53

Documentation ΒΆ

Overview ΒΆ

Package fft provides in-place discrete Fourier transform on powers-of-two subgroups of 𝔽ᡣˣ (the multiplicative group (β„€/rβ„€, x) ).

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

func BitReverse ΒΆ

func BitReverse(v []fr.Element)

BitReverse applies the bit-reversal permutation to v. len(v) must be a power of 2

func BuildExpTable ΒΆ added in v0.13.0

func BuildExpTable(w fr.Element, table []fr.Element)

BuildExpTable precomputes the first n powers of w in parallel table[0] = w^0 table[1] = w^1 ...

func Generator ΒΆ added in v0.10.0

func Generator(m uint64) (fr.Element, error)

Generator returns a generator for Z/2^(log(m))Z or an error if m is too big (required root of unity doesn't exist)

func GeneratorFullMultiplicativeGroup ΒΆ added in v0.13.0

func GeneratorFullMultiplicativeGroup() fr.Element

GeneratorFullMultiplicativeGroup returns a generator of 𝔽ᡣˣ

Types ΒΆ

type Decimation ΒΆ

type Decimation uint8

Decimation is used in the FFT call to select decimation in time or in frequency

const (
	DIT Decimation = iota
	DIF
)

type Domain ΒΆ

type Domain struct {
	Cardinality            uint64
	CardinalityInv         fr.Element
	Generator              fr.Element
	GeneratorInv           fr.Element
	FrMultiplicativeGen    fr.Element // generator of Fr*
	FrMultiplicativeGenInv fr.Element
	// contains filtered or unexported fields
}

Domain with a power of 2 cardinality compute a field element of order 2x and store it in FinerGenerator all other values can be derived from x, GeneratorSqrt

func NewDomain ΒΆ

func NewDomain(m uint64, opts ...DomainOption) *Domain

NewDomain returns a subgroup with a power of 2 cardinality cardinality >= m shift: when specified, it's the element by which the set of root of unity is shifted.

func (*Domain) CosetTable ΒΆ

func (d *Domain) CosetTable() ([]fr.Element, error)

CosetTable returns the cosetTable u*<1,g,..,g^(n-1)> or an error if the domain was created with the WithoutPrecompute option

func (*Domain) CosetTableInv ΒΆ

func (d *Domain) CosetTableInv() ([]fr.Element, error)

CosetTableInv returns the cosetTableInv u*<1,g,..,g^(n-1)> or an error if the domain was created with the WithoutPrecompute option

func (*Domain) FFT ΒΆ

func (domain *Domain) FFT(a []fr.Element, decimation Decimation, opts ...Option)

FFT computes (recursively) the discrete Fourier transform of a and stores the result in a if decimation == DIT (decimation in time), the input must be in bit-reversed order if decimation == DIF (decimation in frequency), the output will be in bit-reversed order

func (*Domain) FFTInverse ΒΆ

func (domain *Domain) FFTInverse(a []fr.Element, decimation Decimation, opts ...Option)

FFTInverse computes (recursively) the inverse discrete Fourier transform of a and stores the result in a if decimation == DIT (decimation in time), the input must be in bit-reversed order if decimation == DIF (decimation in frequency), the output will be in bit-reversed order coset sets the shift of the fft (0 = no shift, standard fft) len(a) must be a power of 2, and w must be a len(a)th root of unity in field F.

func (*Domain) ReadFrom ΒΆ

func (d *Domain) ReadFrom(r io.Reader) (int64, error)

ReadFrom attempts to decode a domain from Reader

func (*Domain) Twiddles ΒΆ

func (d *Domain) Twiddles() ([][]fr.Element, error)

Twiddles returns the twiddles factor for the FFT using Generator for each stage of the recursive FFT or an error if the domain was created with the WithoutPrecompute option

func (*Domain) TwiddlesInv ΒΆ

func (d *Domain) TwiddlesInv() ([][]fr.Element, error)

TwiddlesInv returns the twiddles factor for the FFT using GeneratorInv for each stage of the recursive FFT or an error if the domain was created with the WithoutPrecompute option

func (*Domain) WriteTo ΒΆ

func (d *Domain) WriteTo(w io.Writer) (int64, error)

WriteTo writes a binary representation of the domain (without the precomputed twiddle factors) to the provided writer

type DomainOption ΒΆ added in v0.13.0

type DomainOption func(*domainConfig)

DomainOption defines option for altering the definition of the FFT domain See the descriptions of functions returning instances of this type for particular options.

func WithShift ΒΆ added in v0.13.0

func WithShift(shift fr.Element) DomainOption

WithShift sets the FrMultiplicativeGen of the domain. Default is generator of the largest 2-adic subgroup.

func WithoutPrecompute ΒΆ added in v0.13.0

func WithoutPrecompute() DomainOption

WithoutPrecompute disables precomputation of twiddles in the domain. When this option is set, FFTs will be slower, but will use less memory.

type Option ΒΆ added in v0.10.0

type Option func(*fftConfig)

Option defines option for altering the behavior of FFT methods. See the descriptions of functions returning instances of this type for particular options.

func OnCoset ΒΆ added in v0.10.0

func OnCoset() Option

OnCoset if provided, FFT(a) returns the evaluation of a on a coset.

func WithNbTasks ΒΆ added in v0.10.0

func WithNbTasks(nbTasks int) Option

WithNbTasks sets the max number of task (go routine) to spawn. Must be between 1 and 512.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL