c128

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package c128 provides SIMD-accelerated operations on complex128 slices.

These operations are designed to accelerate FFT-based convolution pipelines: - Mul: Complex multiplication for frequency-domain convolution - MulConj: Multiply by conjugate for correlation - Scale: Scale by complex scalar

All functions automatically select the optimal implementation based on runtime CPU feature detection. Functions gracefully fall back to pure Go implementations on unsupported architectures.

Thread Safety: All functions are safe for concurrent use. Memory: All functions are zero-allocation (no heap allocations).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs added in v1.0.7

func Abs(dst []float64, a []complex128)

Abs computes element-wise complex magnitude: dst[i] = |a[i]|. Processes min(len(dst), len(a)) elements.

Magnitude: |a + bi| = sqrt(a² + b²)

This is the core operation for spectrograms and frequency-domain analysis.

func AbsSq added in v1.0.7

func AbsSq(dst []float64, a []complex128)

AbsSq computes element-wise magnitude squared: dst[i] = |a[i]|². Processes min(len(dst), len(a)) elements.

Magnitude squared: |a + bi|² = a² + b²

This is faster than Abs (no sqrt) and useful for power spectrograms.

func Add

func Add(dst, a, b []complex128)

Add computes element-wise complex addition: dst[i] = a[i] + b[i]. Processes min(len(dst), len(a), len(b)) elements.

func Conj added in v1.0.7

func Conj(dst, a []complex128)

Conj computes element-wise complex conjugate: dst[i] = conj(a[i]). Processes min(len(dst), len(a)) elements.

Conjugate: conj(a + bi) = a - bi

func Mul

func Mul(dst, a, b []complex128)

Mul computes element-wise complex multiplication: dst[i] = a[i] * b[i]. Processes min(len(dst), len(a), len(b)) elements.

Complex multiplication: (a + bi)(c + di) = (ac - bd) + (ad + bc)i

This is the core operation for FFT-based convolution in frequency domain.

func MulConj

func MulConj(dst, a, b []complex128)

MulConj computes element-wise multiplication by conjugate: dst[i] = a[i] * conj(b[i]). Processes min(len(dst), len(a), len(b)) elements.

MulConj: (a + bi)(c - di) = (ac + bd) + (bc - ad)i

This is used for cross-correlation in frequency domain.

func Scale

func Scale(dst, a []complex128, s complex128)

Scale multiplies each element by a complex scalar: dst[i] = a[i] * s. Processes min(len(dst), len(a)) elements.

func Sub

func Sub(dst, a, b []complex128)

Sub computes element-wise complex subtraction: dst[i] = a[i] - b[i]. Processes min(len(dst), len(a), len(b)) elements.

Types

This section is empty.

Jump to

Keyboard shortcuts

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