Want to take part in these discussions? Sign in if you have an account, or apply for one below
Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.
some ideas:
1) try replacing prior NaNs with MachineParameterDouble.eps instead of 0
2) find out, why any NaN exist at all (they shouldn't be there, I suppose?)
3) make sure, you are using the proper datatype (single ? double? complex double? etc... )
4) make sure, the array is properly detached from the DS buffer (by COPYING from the buffer or by cloning the array)
If nothing helps, please post your code here and/or prepare a small test case for reference and reproducability. (I doubt, the reason is in the fft)
Just some thoughts on possible optimizations... :
private double[] processData(double[] data) //why not take an ILArray<double> here?
{
//create new ILArray from data to process
ILArray<double> dataToProcess = new ILArray<double>(data);
//compute 1D FFT on dataToProcess
ILArray<ILNumerics.complex> processedData = ILMath.fft(dataToProcess);
//get length of processedData
// // the loop can be replaced by:
// processedData[startIndex + ":" + endIndex] /= 2.0;
// // (precomputed startIndex, endIndex)
int theLength = processedData.Length / 2;
for (int i = 0; i < theLength; i++)
{
ILNumerics.complex c = (ILNumerics.complex)processedData[i];
//get frequency at i
double freq = Common.sampleRate * i / theLength; // sampleRate / 2!
if (freq >= Common.lBound && freq <= Common.uBound) // amplify this region
{
c.real /= 2;
}
}
ILArray<double> fData = ILMath.real(ILMath.ifft(processedData));
double[] final = fData.Values.ToArray<double>();
return final; //change this later
// why not return ILArray<double>?
}
Regarding NaN: make sure, not to confuse byte / double datatypes! This would produce NaNs as well. Make sure, no NaNs are coming from buffer. Checks on NaN can be done with:
find(isnan(fprocBuf)).Length > 0, or
fprocBuf[find(isnan(fprocBuf))] = MachineParameterDouble.eps
1 to 5 of 5