This bugzilla service is closed. All entries have been migrated to
Bug 675 - Fixed-size FFT cash
Summary: Fixed-size FFT cash
Status: NEW
Alias: None
Product: Eigen
Classification: Unclassified
Component: Unsupported modules (show other bugs)
Version: 3.2
Hardware: All All
: Normal Unknown
Assignee: Nobody
Depends on:
Reported: 2013-10-10 11:06 UTC by zhangguoxiang
Modified: 2019-12-04 12:41 UTC (History)
0 users


Description zhangguoxiang 2013-10-10 11:06:55 UTC
I find a bug in a function of unsupported/Eigen/FFT file:
Line 221 :
void fwd( MatrixBase<ComplexDerived> & dst, const MatrixBase<InputDerived> & src, Index nfft=-1)
When nfft is bigger than the length of src, this bug appears.Such as:

#include <unsupported/Eigen/FFT>
int main()
    Eigen::VectorXf timevec(10);
    Eigen::VectorXcf freqvec;
    Eigen::FFT<float> fft;
    fft.fwd(freqvec, timevec,16); //16 is bigger than the length of timevec
    std::cout<< "freqvec is:\n"<< freqvec <<std::endl;
    return 0;

In the file I download, There are:

Line 242:    Matrix<src_type,1,Dynamic> tmp;
             if (src.size()<nfft) {
                 tmp.block(0,0,src.size(),1 ) = src;

The statement tmp.block(0,0,src.size(),1 ) will beyond the Matrix.
It should be tmp.block(0,0,1 ,src.size()).

What’s more, when src is a Vector not a RowVector, program will crash when running.
So I think the correct code is:

        Matrix<src_type,1,Dynamic> tmp;
        if (src.size()<nfft) {
	     if(src.cols() !=1)
	          tmp.block(0,0,1 ,src.size()) = src;
	     tmp.block(0,0,1 ,src.size()) = src.transpose();
The code above has been tested, and it works well. I think it maybe rewrite by using more professional condition statement to judge that src is a Vector or RowVector.
Comment 1 Nobody 2019-12-04 12:41:05 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance:

Note You need to log in before you can comment on or make changes to this bug.