fft

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 10 Imported by: 36

Documentation

Overview

Package fft provides in-place discrete Fourier transform.

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 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)

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

	// Twiddles factor for the FFT using Generator for each stage of the recursive FFT
	Twiddles [][]fr.Element

	// Twiddles factor for the FFT using GeneratorInv for each stage of the recursive FFT
	TwiddlesInv [][]fr.Element

	// CosetTable u*<1,g,..,g^(n-1)>
	CosetTable []fr.Element

	// CosetTable[i][j] = domain.Generator(i-th)SqrtInv ^ j
	CosetTableInv []fr.Element
}

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, shift ...fr.Element) *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) AsyncReadFrom added in v0.11.2

func (d *Domain) AsyncReadFrom(r io.Reader) (int64, error, chan struct{})

AsyncReadFrom attempts to decode a domain from Reader. It returns a channel that will be closed when the precomputation is done.

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) 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 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