I'm coding a Fast Fourier Transform algorithm that does the Cooley Tukey method recursively using complex vectors. The header file and the .cpp file match in parameter name and syntax, but I get the 'undefined reference' error still. Due to the "extra" allocator parameter being mentioned in the error. I think this might have something to do with using a template for our abstract base class and derived Cooley-tukey class. All of the problems have come from the FFF_REC function that recursively divides up the input.
Github: https://github.com/ProgrammerB/Fourier-Transform-Terminal-/blob/master/classes/cooley-tukey.h
I've already tried to change my parameters to references and add a private member into the cooley-tukey class, but I get the same error.
Cooley-Tukey Class:
template<typename T>
class Cooley_tukey: protected Fourier<T>{
public:
Cooley_tukey();
Cooley_tukey(std::string file_name, double frequency, double,
frequency_step, std::string output_name);
//~Cooley_tukey();
void FFT(const std::vector<T> &index, const std::vector<T> &value);
std::vector<complex<T>> FFT_REC(std::vector<complex<T>> &temp, int
total_time); //recursion function for FFT
private:
int total_time;
};
Part of the error:
classes\cooley-tukey.cpp:91:10: error: no matching function for call to
'Cooley_tukey<double>::FFT_REC(std::vector<std::complex<double>,
std::allocator<std::complex<double> > > [(total_time / 2)], int,
std::vector<std::complex<double>, std::allocator<std::complex<double> >
>&)'FFT_REC(odd, total_time/2, result);
FFT-Recursion function(source of errors):
template<typename T>
std::vector<complex<T>> Cooley_tukey<T>::FFT_REC(std::vector<complex<T>>& temp, int total_time)
{
// Check if it is split up enough
if (total_time >= 2)
{
// Split even and odds up
std::vector<complex<T>> odd[total_time/2];
std::vector<complex<T>> even[total_time/2];
for (int i = 0; i < total_time / 2; i++)
{
even->at(i) = temp.at(i*2);
odd->at(i) = temp.at(i*2+1);
}
// Split up tasks through FFT recursion method
FFT_REC(even, total_time/2);
FFT_REC(odd, total_time/2);
// DFT portion of FFT - calculates after everything has been split up through FFT_REC
for (int frequency = 0; frequency < total_time / 2; frequency += this->frequency_step)
{
std::complex<T> t = exp(std::complex<T>(0, -2 * M_PI * frequency / total_time)) * odd->at(frequency);
//Result of Cooley-Tukey algorithm:
//*This gives us the frequency values at certain times
temp.at(frequency) = even->at(frequency) + t;
temp.at(total_time / 2 + frequency) = even->at(frequency) - t;
}
}
return temp;
}
template class Cooley_tukey<double>;