Fix fft and add hilbert
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "CudaMatrix.h"
|
||||
#include "Function1D.h"
|
||||
#include "Function1D.cuh"
|
||||
#include "Function3D.h"
|
||||
#include "Matrix.h"
|
||||
#include <Function2D.cuh>
|
||||
#include <cfloat>
|
||||
@@ -1355,9 +1356,7 @@ if (aMatrix.isComplex()){
|
||||
complexFillKernel<<<aMatrix.getDimSize(1), 256>>>(aMatrix.getData(), data, needCopySize, aMatrix.getDimSize(0),ColEleCount);
|
||||
}
|
||||
auto ret = Aurora::CudaMatrix::fromRawData(data,ColEleCount,aMatrix.getDimSize(1),1,Complex);
|
||||
auto mm = ret.toHostMatrix();
|
||||
ExecFFT(ret,0);
|
||||
mm = ret.toHostMatrix();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1547,4 +1546,15 @@ CudaMatrix Aurora::ifft_symmetric(const CudaMatrix &aMatrix, long aLength)
|
||||
ifft_symmetricKernel<<<blocksPerGrid, THREADS_PER_BLOCK>>>(data, aLength / 2 - 1);
|
||||
cudaDeviceSynchronize();
|
||||
return real(ifft(CudaMatrix::fromRawData(data,aLength,1,1,Complex)));
|
||||
}
|
||||
|
||||
CudaMatrix Aurora::hilbert(const CudaMatrix &aMatrix){
|
||||
auto x = fft(aMatrix);
|
||||
auto h = Aurora::zerosCuda(aMatrix.getDimSize(0),1,1);
|
||||
thrust::fill_n(thrust::device, h.getData(), aMatrix.getDimSize(0) / 2, 2.0f);
|
||||
h.setValue(aMatrix.getDimSize(0) / 2, ((aMatrix.getDimSize(0) << 31) >> 31) ? 2.0 : 1.0);
|
||||
h.setValue(0, 1.0f);
|
||||
x = x*h;
|
||||
auto result = ifft( x);
|
||||
return result;
|
||||
}
|
||||
@@ -65,6 +65,8 @@ namespace Aurora
|
||||
CudaMatrix fft(const CudaMatrix &aMatrix, long aFFTSize = -1);
|
||||
CudaMatrix ifft(const CudaMatrix &aMatrix, long aFFTSize = -1);
|
||||
|
||||
CudaMatrix hilbert(const CudaMatrix &aMatrix);
|
||||
|
||||
void fftshift(CudaMatrix &aMatrix);
|
||||
void ifftshift(CudaMatrix &aMatrix);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user