Example #1
0
// Zop computes an out-of-place single-precision complex discrete Fourier transform of the
// input vector, either from the time domain to the frequency domain (forward) or from the
// frequency domain to the time domain (inverse).
func (fs *FFTSetupD) Zop(input DSPDoubleSplitComplex, inputStride int, output DSPDoubleSplitComplex, outputStride int, log2n int, direction FFTDirection) {
	var inC C.DSPDoubleSplitComplex
	inC.realp = (*C.double)(&input.Real[0])
	inC.imagp = (*C.double)(&input.Imag[0])
	var outC C.DSPDoubleSplitComplex
	outC.realp = (*C.double)(&output.Real[0])
	outC.imagp = (*C.double)(&output.Imag[0])
	C.vDSP_fft_zopD(fs.cFFTSetupD, &inC, C.vDSP_Stride(inputStride), &outC, C.vDSP_Stride(outputStride), C.vDSP_Length(log2n), C.FFTDirection(direction))
}
Example #2
0
// Zidotpr calculates the conjugate dot product (or inner dot product) of complex vectors A and B and leave the result in complex vector C; single precision.
func Zidotpr(input1 DSPSplitComplex, stride1 int, input2 DSPSplitComplex, stride2 int, result DSPSplitComplex) {
	var in1 C.DSPSplitComplex
	in1.realp = (*C.float)(&input1.Real[0])
	in1.imagp = (*C.float)(&input1.Imag[0])
	var in2 C.DSPSplitComplex
	in2.realp = (*C.float)(&input2.Real[0])
	in2.imagp = (*C.float)(&input2.Imag[0])
	var res C.DSPSplitComplex
	res.realp = (*C.float)(&result.Real[0])
	res.imagp = (*C.float)(&result.Imag[0])
	C.vDSP_zidotpr(&in1, C.vDSP_Stride(stride1), &in2, C.vDSP_Stride(stride2), &res, C.vDSP_Length(len(result.Real)))
}
Example #3
0
// Zvcmul performs a complex vector conjugate and multiply.
func Zvcmul(input1 DSPSplitComplex, stride1 int, input2 DSPSplitComplex, stride2 int, result DSPSplitComplex, resultStride int) {
	var in1 C.DSPSplitComplex
	in1.realp = (*C.float)(&input1.Real[0])
	in1.imagp = (*C.float)(&input1.Imag[0])
	var in2 C.DSPSplitComplex
	in2.realp = (*C.float)(&input2.Real[0])
	in2.imagp = (*C.float)(&input2.Imag[0])
	var res C.DSPSplitComplex
	res.realp = (*C.float)(&result.Real[0])
	res.imagp = (*C.float)(&result.Imag[0])
	C.vDSP_zvcmul(&in1, C.vDSP_Stride(stride1), &in2, C.vDSP_Stride(stride2), &res, C.vDSP_Stride(resultStride), minLen(len(input1.Real)/stride1, len(input2.Real)/stride2, len(result.Real)/resultStride))
}
Example #4
0
// Zrdesamp performs a complex-real downsample with anti-aliasing.
func Zrdesamp(input DSPSplitComplex, decimationFactor int, coefficients []float32, output DSPSplitComplex) {
	var srcC C.DSPSplitComplex
	srcC.realp = (*C.float)(&input.Real[0])
	srcC.imagp = (*C.float)(&input.Imag[0])
	var dstC C.DSPSplitComplex
	dstC.realp = (*C.float)(&output.Real[0])
	dstC.imagp = (*C.float)(&output.Imag[0])
	C.vDSP_zrdesamp(&srcC, C.vDSP_Stride(decimationFactor), (*C.float)(&coefficients[0]), &dstC, C.vDSP_Length(len(output.Real)), C.vDSP_Length(len(coefficients)))
}
Example #5
0
// Ctoz copies the contents of an interleaved complex vector C to a split complex vector Z; single precision.
func Ctoz(input []complex64, inputStride int, output DSPSplitComplex, outputStride int) {
	var splitComplex C.DSPSplitComplex
	splitComplex.realp = (*C.float)(&output.Real[0])
	splitComplex.imagp = (*C.float)(&output.Imag[0])
	n := 2 * len(output.Real) / outputStride
	if n2 := 2 * len(input) / inputStride; n2 < n {
		n = n2
	}
	C.vDSP_ctoz((*C.DSPComplex)(unsafe.Pointer(&input[0])), C.vDSP_Stride(inputStride), &splitComplex, C.vDSP_Stride(outputStride), C.vDSP_Length(n))
}
Example #6
0
// Vector scalar add; single precision.
func Vsadd(input []float32, inputStride int, add float32, output []float32, outputStride int) {
	C.vDSP_vsadd((*C.float)(&input[0]), C.vDSP_Stride(inputStride), (*C.float)(&add), (*C.float)(&output[0]), C.vDSP_Stride(outputStride), C.vDSP_Length(len(output)/outputStride))
}
Example #7
0
// Vector scalar divide; single precision.
func Vsdiv(input []float32, inputStride int, divisor float32, output []float32, outputStride int) {
	C.vDSP_vsdiv((*C.float)(&input[0]), C.vDSP_Stride(inputStride), (*C.float)(&divisor), (*C.float)(&output[0]), C.vDSP_Stride(outputStride), C.vDSP_Length(len(output)/outputStride))
}
Example #8
0
// Vdpsp_byte converts a double-precision to single-precision.
// Operate on a byte buffer which contains float64
func Vdpsp_byte(input []byte, inputStride int, output []float32, outputStride int) {
	C.vDSP_vdpsp((*C.double)(unsafe.Pointer(&input[0])), C.vDSP_Stride(inputStride), (*C.float)(&output[0]), C.vDSP_Stride(outputStride), minLen(len(input)/8/inputStride, len(output)/outputStride))
}
Example #9
0
// Zvphas calculates the complex vector phase.
func Zvphas(input DSPSplitComplex, inputStride int, output []float32, outputStride int) {
	var srcC C.DSPSplitComplex
	srcC.realp = (*C.float)(&input.Real[0])
	srcC.imagp = (*C.float)(&input.Imag[0])
	C.vDSP_zvphas(&srcC, C.vDSP_Stride(inputStride), (*C.float)(&output[0]), C.vDSP_Stride(outputStride), C.vDSP_Length(len(output)))
}
Example #10
0
// Vfltu8 converts an array of unsigned 8-bit integers to single-precision floating-point values.
func Vfltu8(input []byte, inputStride int, output []float32, outputStride int) {
	C.vDSP_vfltu8((*C.uchar)(&input[0]), C.vDSP_Stride(inputStride), (*C.float)(&output[0]), C.vDSP_Stride(outputStride), minLen(len(input)/inputStride, len(output)/outputStride))
}
Example #11
0
// Vflt32_byte converts an array of signed 16-bit integers to single-precision floating-point values.
func Vflt32_byte(input []byte, inputStride int, output []float32, outputStride int) {
	C.vDSP_vflt32((*C.int)(unsafe.Pointer(&input[0])), C.vDSP_Stride(inputStride), (*C.float)(&output[0]), C.vDSP_Stride(outputStride), minLen(len(input)/(4*inputStride), len(output)/outputStride))
}
Example #12
0
// Vsmsa is vector scalar multiply and scalar add; single precision.
// output[n] = input[n] * mult + add
func Vsmsa(input []float32, inputStride int, mult, add float32, output []float32, outputStride int) {
	C.vDSP_vsmsa((*C.float)(&input[0]), C.vDSP_Stride(inputStride), (*C.float)(&mult), (*C.float)(&add), (*C.float)(&output[0]), C.vDSP_Stride(outputStride), minLen(len(input)/inputStride, len(output)/outputStride))
}
Example #13
0
// Vector convert power or amplitude to decibels; single precision.
// α * log10(input(n)/zeroReference) [α is 20 if Amplitude (flag=1), or 10 if F is Power (flag=0)]
func Vdbcon(input []float32, inputStride int, zeroReference float32, output []float32, outputStride int, flag DBFlag) {
	C.vDSP_vdbcon((*C.float)(&input[0]), C.vDSP_Stride(inputStride), (*C.float)(&zeroReference), (*C.float)(&output[0]), C.vDSP_Stride(outputStride), C.vDSP_Length(len(output)/outputStride), C.uint(flag))
}
Example #14
0
// Vfix16_byte converts an array of single-precision floating-point values to signed 16-bit integer values, rounding towards zero. Output to a byte stream.
func Vfix16_byte(input []float32, inputStride int, output []byte, outputStride int) {
	C.vDSP_vfix16((*C.float)(&input[0]), C.vDSP_Stride(inputStride), (*C.short)(unsafe.Pointer(&output[0])), C.vDSP_Stride(outputStride), C.vDSP_Length(len(output)/2/outputStride))
}
Example #15
0
// Vadd adds two vectors.
func Vadd(input1 []float32, input1Stride int, input2 []float32, input2Stride int, output []float32, outputStride int) {
	C.vDSP_vadd((*C.float)(&input1[0]), C.vDSP_Stride(input1Stride), (*C.float)(&input2[0]), C.vDSP_Stride(input2Stride), (*C.float)(&output[0]), C.vDSP_Stride(outputStride), minLen(len(input1)/input1Stride, len(input2)/input2Stride, len(output)/outputStride))
}
Example #16
0
// Vfix16 converts an array of single-precision floating-point values to signed 16-bit integer values, rounding towards zero.
func Vfix16(input []float32, inputStride int, output []int16, outputStride int) {
	C.vDSP_vfix16((*C.float)(&input[0]), C.vDSP_Stride(inputStride), (*C.short)(&output[0]), C.vDSP_Stride(outputStride), minLen(len(input)/inputStride, len(output)/outputStride))
}
Example #17
0
// Vclip clips the input vector using the given low and high and writes
// the result to the output vector.
func Vclip(input []float32, inputStride int, low, high float32, output []float32, outputStride int) {
	C.vDSP_vclip((*C.float)(&input[0]), C.vDSP_Stride(inputStride), (*C.float)(&low), (*C.float)(&high), (*C.float)(&output[0]), C.vDSP_Stride(outputStride), minLen(len(input)/inputStride, len(output)/outputStride))
}
Example #18
0
// Vthr thresholds the input vector writing the the result ot the output vector.
func Vthr(input []float32, inputStride int, low float32, output []float32, outputStride int) {
	C.vDSP_vthr((*C.float)(&input[0]), C.vDSP_Stride(inputStride), (*C.float)(&low), (*C.float)(&output[0]), C.vDSP_Stride(outputStride), minLen(len(input)/inputStride, len(output)/outputStride))
}
Example #19
0
// Vector negative values; single precision.
func Vneg(input []float32, inputStride int, output []float32, outputStride int) {
	C.vDSP_vneg((*C.float)(&input[0]), C.vDSP_Stride(inputStride), (*C.float)(&output[0]), C.vDSP_Stride(outputStride), C.vDSP_Length(len(output)/outputStride))
}
Example #20
0
// Complex vector absolute values; double precision.
func ZvabsD(input DSPDoubleSplitComplex, inputStride int, output []float64, outputStride int) {
	var in C.DSPDoubleSplitComplex
	in.realp = (*C.double)(&input.Real[0])
	in.imagp = (*C.double)(&input.Imag[0])
	C.vDSP_zvabsD(&in, C.vDSP_Stride(inputStride), (*C.double)(&output[0]), C.vDSP_Stride(outputStride), C.vDSP_Length(len(output)/outputStride))
}
Example #21
0
// Vector sliding window sum; single precision.
func Vswsum(input []float32, inputStride int, output []float32, outputStride, windowLen int) {
	C.vDSP_vswsum((*C.float)(&input[0]), C.vDSP_Stride(inputStride), (*C.float)(&output[0]), C.vDSP_Stride(outputStride), C.vDSP_Length(len(output)/outputStride), C.vDSP_Length(windowLen))
}
Example #22
0
// Vector minimum value; single precision.
func Minv(input []float32, stride int) float32 {
	var out C.float
	C.vDSP_minv((*C.float)(&input[0]), C.vDSP_Stride(stride), &out, C.vDSP_Length(len(input)/stride))
	return float32(out)
}
Example #23
0
// Meanv returns the mean of the input vector.
func Meanv(input []float32, stride int) float32 {
	var mean C.float
	C.vDSP_meanv((*C.float)(&input[0]), C.vDSP_Stride(stride), &mean, C.vDSP_Length(len(input)/stride))
	return float32(mean)
}
Example #24
0
// Ztoc_byte copies the contents of a split complex vector Z to an interleaved complex vector C; single precision. Operate on a byte buffer which contains complex64
func Ztoc_byte(input DSPSplitComplex, inputStride int, output []byte, outputStride int) {
	var splitComplex C.DSPSplitComplex
	splitComplex.realp = (*C.float)(&input.Real[0])
	splitComplex.imagp = (*C.float)(&input.Imag[0])
	C.vDSP_ztoc(&splitComplex, C.vDSP_Stride(inputStride), (*C.DSPComplex)(unsafe.Pointer(&output[0])), C.vDSP_Stride(outputStride), C.vDSP_Length(len(output)/4/outputStride))
}
Example #25
0
// Vflt32 converts an array of signed 32-bit integers to single-precision floating-point values.
func Vflt32(input []int32, inputStride int, output []float32, outputStride int) {
	C.vDSP_vflt32((*C.int)(&input[0]), C.vDSP_Stride(inputStride), (*C.float)(&output[0]), C.vDSP_Stride(outputStride), minLen(len(input)/inputStride, len(output)/outputStride))
}
Example #26
0
// Vector linear average; single precision.
func Vavlin(input []float32, inputStride int, count float32, output []float32, outputStride int) {
	C.vDSP_vavlin((*C.float)(&input[0]), C.vDSP_Stride(inputStride), (*C.float)(&count), (*C.float)(&output[0]), C.vDSP_Stride(outputStride), C.vDSP_Length(len(output)/outputStride))
}
Example #27
0
// Vdpsp convert a double-precision vector to single-precision.
func Vdpsp(input []float64, inputStride int, output []float32, outputStride int) {
	C.vDSP_vdpsp((*C.double)(&input[0]), C.vDSP_Stride(inputStride), (*C.float)(&output[0]), C.vDSP_Stride(outputStride), minLen(len(input)/inputStride, len(output)/outputStride))
}
Example #28
0
// Multiplies vector A by vector B and leaves the result in vector C; single precision.
func Vmul(input1 []float32, stride1 int, input2 []float32, stride2 int, output []float32, outputStride int) {
	C.vDSP_vmul((*C.float)(&input1[0]), C.vDSP_Stride(stride1), (*C.float)(&input2[0]), C.vDSP_Stride(stride2), (*C.float)(&output[0]), C.vDSP_Stride(outputStride), C.vDSP_Length(len(output)/outputStride))
}
Example #29
0
// Vector sum; single precision.
func Sve(input []float32, inputStride int) float32 {
	var sum C.float
	C.vDSP_sve((*C.float)(&input[0]), C.vDSP_Stride(inputStride), &sum, C.vDSP_Length(len(input)/inputStride))
	return float32(sum)
}
Example #30
0
// Desamp performs convolution with decimation.
func Desamp(input []float32, desamplingFactor int, coeff []float32, output []float32) {
	C.vDSP_desamp((*C.float)(&input[0]), C.vDSP_Stride(desamplingFactor), (*C.float)(&coeff[0]), (*C.float)(&output[0]), C.vDSP_Length(len(output)), C.vDSP_Length(len(coeff)))
}