Add ifft_symmetric and its unit test.

This commit is contained in:
kradchen
2023-05-05 13:22:15 +08:00
parent c967788302
commit 5353aa53d5
4 changed files with 70 additions and 30 deletions

View File

@@ -670,7 +670,7 @@ Matrix Aurora::ifft(const Matrix &aMatrix) {
//提交 修改配置后的Descriptor(实际上会进行FFT的计算初始化)
status = DftiCommitDescriptor(my_desc_handle);
if (status != DFTI_NO_ERROR) goto error;
//执行计算
status = DftiComputeBackward(my_desc_handle, aMatrix.getData(), output);
if (status != DFTI_NO_ERROR) goto error;
@@ -685,6 +685,28 @@ Matrix Aurora::ifft(const Matrix &aMatrix) {
return Matrix();
}
Matrix Aurora::ifft_symmetric(const Matrix &aMatrix,long length)
{
if(!aMatrix.isVector()){
std::cerr<<"ifft_symmetric only support vector!"<<std::endl;
return Matrix();
}
int matrixLength = aMatrix.getDataSize();
int resultHalfLength = (int)std::ceil(((double)length*0.5));
int copyLength = resultHalfLength<matrixLength?resultHalfLength:matrixLength;
double* calcData = malloc(length,true);
double zero = 0.0;
//所有数据统一置0
cblas_dcopy(length*2,&zero,0,calcData,1);
//copy前半段数据
cblas_zcopy(copyLength,aMatrix.getData(),1,calcData,1);
//copy后半段数据,跳过index 0的值,并设置虚部共轭
vdAddI(copyLength-1,&zero,0,(aMatrix.getData()+2),2,(calcData+(length-1)*2),-2);
vdSubI(copyLength-1,&zero,0,(aMatrix.getData()+2+1),2,(calcData+(length-1)*2+1),-2);
return real(ifft(Matrix::New(calcData,length,1,1,Complex)));
}
Matrix Aurora::hilbert(const Matrix &aMatrix) {
auto x = fft(aMatrix);
auto h = malloc(aMatrix.getDimSize(0));