Documentation
¶
Index ¶
- Constants
- func Convolve(x, y []complex128) []complex128
- func FFT(src []complex128) []complex128
- func GetRadix2Factors(inputLen int) []complex128
- func IFFT(value []complex128) []complex128
- func Log2[T Log2Types](v T) T
- func ReorderData(value []complex128) []complex128
- func ReverseBits[T RevBitsTypes](value T) (reverse T)
- func ReverseFirstBits[T RevBitsTypes](value, size T) (reverse T)
- func ToComplex(x []float64) []complex128
- type Log2Types
- type RevBitsTypes
Constants ¶
const ( // DefaultMagnitudeThreshold describes the default value where a certain // frequency is strong enough to be considered relevant to the spectrum filter. DefaultMagnitudeThreshold = 10 )
Variables ¶
This section is empty.
Functions ¶
func Convolve ¶
func Convolve(x, y []complex128) []complex128
Convolve returns the convolution of x ∗ y, applied to the complex128 slice x.
func FFT ¶
func FFT(src []complex128) []complex128
FFT applies a Fast Fourier Transform to the input slice of complex128 values, to retrieve the frequency spectrum of a digital signal.
func GetRadix2Factors ¶
func GetRadix2Factors(inputLen int) []complex128
GetRadix2Factors is temporarily public, could become private at a later point.
func IFFT ¶
func IFFT(value []complex128) []complex128
IFFT returns the Inverse Fast Fourier Transform of a given complex128 slice.
func Log2 ¶
func Log2[T Log2Types](v T) T
Log2 returns the log base 2 of v, matching the input to precomputed values to achieve the fastest performance possible.
If the input is not present, then its log2 value is computed with a fast bit-shifting technique.
from: http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogObvious
func ReorderData ¶
func ReorderData(value []complex128) []complex128
ReorderData shuffles the input complex128 values to re-order it, setting the first half of the slice in even indexes and the last half of the slice in odd indexes.
func ReverseBits ¶
func ReverseBits[T RevBitsTypes](value T) (reverse T)
ReverseBits returns the bits of `value` in reverse order from: http://graphics.stanford.edu/~seander/bithacks.html#BitReverseObvious
func ReverseFirstBits ¶
func ReverseFirstBits[T RevBitsTypes](value, size T) (reverse T)
ReverseFirstBits returns the first `size` bits of `value` in reverse order from: http://graphics.stanford.edu/~seander/bithacks.html#BitReverseObvious
func ToComplex ¶
func ToComplex(x []float64) []complex128
ToComplex converts a slice of float64 into a slice of complex128, where the input slice's values are set as the real part of the complex numbers
In Go, a complex number is a pair of two float numbers. This means that converting a float number to a complex number only makes it necessary to assign the (float's) value as the real part of the complex number, leaving the imaginary as zero.
This particular function leverages that by creating a float slice of twice the size as the inputs, and placing each element of the input on every second slot. Finally, it casts this float slice as a complex slice, using an unsafe approach to prioritize performance.