Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatVecProdCR ¶
func MatVecProdCR(A [][]complex128, x []float64, out []complex128) []complex128
MatVecProd computes the matrix-vector product Ax for (nxm) matrix A and (1xm) vector B, storing it in out
func NewDenseMatrixC ¶
func NewDenseMatrixC(r, c int, data []complex128) [][]complex128
NewDenseMatrix produces a new (rxc) matrix backed by contiguous data. this function produces superior memory access patterns and prevents the rows of the output from being scattered in memory.
data may be nil, in which case an array of zeros is returned
func VecAbs ¶
func VecAbs(in []complex128, out []float64) []float64
Types ¶
type MatrixDFTExecutor ¶
type MatrixDFTExecutor struct {
// contains filtered or unexported fields
}
MatrixDFTExecutor performs Discrete Fourier Transforms (DFTs) using a matrix-vector product. The type is not thread-safe.
MatrixDFTExecutor.RunR() performs a DFT, returning the result.
no shifts are required of the input or the output.
The return of MatrixDFTExecutor.RunR() is a view into pre-allocated memory. The caller may mutate the array, but should understand the array will be overwritten on the next RunR() call.
It is typical to examine the magnitude or phase of the DFT result; these operations naturally "copy" the result. If the complex value is to be used, the caller should copy the data into their own slice between RunR() calls.
Recall that the Fourier Transform is the decomposition of a signal into a sine/cosine basis set. For orthogonal bases, the coefficients are simply the dot product of the mode and the data.
in other words, the real part of the DFT at a particular frequency is sx := sin(2*pi*x*f) // sine x cx := cos(2*pi*x*f) // cos x csf := dot(sx, data) // coefficient of sine x ccf := dot(cx, data) // cos x
Recall also Euler's identify, exp(i*x) = sin(c) + i*cos(x); we can perform both dot products simultaneously using complex numbers
Finally, recall that a matrix multiply is simply a row-wise dot product.
Given all these details, the DFT can be expressed as a matrix multiply between a transformation matrix and the data.
This matrix can be pre-computed if the data length and frequencies of interest are not changing. We are also able to compute the DFT for arbitrary frequencies and in particular only those frequencies which are of interest. When performing spectral analysis, this often makes the matrix DFT substantially faster than the FFT.
func NewDFTExecutorFromFreqs ¶
func NewDFTExecutorFromFreqs(N int, dx float64, freqs []float64) MatrixDFTExecutor
func (MatrixDFTExecutor) RunR ¶
func (mft MatrixDFTExecutor) RunR(in []float64) []complex128