fft

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BitReverse

func BitReverse(a []fr.Element)

BitReverse applies the bit-reversal permutation to a. len(a) must be a power of 2 (as in every single function in this file)

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 {
	Generator        fr.Element
	GeneratorInv     fr.Element
	GeneratorSqRt    fr.Element // generator of 2 adic subgroup of order 2*nb_constraints
	GeneratorSqRtInv fr.Element
	Cardinality      int
	CardinalityInv   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[0] = 1
	// CosetTable[0] = domain.GeneratorSqrt ^ 1
	// CosetTable[1] = domain.GeneratorSqrt ^ 2
	// ...
	// CosetTable = fft.BitReverse(CosetTable)
	CosetTable []fr.Element

	// CosetTableInv[0] = 1
	// CosetTableInv[0] = domain.GeneratorSqrtInv ^ 1
	// CosetTableInv[1] = domain.GeneratorSqrtInv ^ 2
	// ...
	// CosetTableInv = fft.BitReverse(CosetTableInv)
	CosetTableInv []fr.Element
}

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

func NewDomain

func NewDomain(m int) *Domain

NewDomain returns a subgroup with a power of 2 cardinality cardinality >= m compute a field element of order 2x and store it in GeneratorSqRt all other values can be derived from x, GeneratorSqrt

func (*Domain) FFT

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

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 len(a) must be a power of 2, and w must be a len(a)th root of unity in field F.

func (*Domain) FFTInverse

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

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 len(a) must be a power of 2, and w must be a len(a)th root of unity in field F.

Jump to

Keyboard shortcuts

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