I'm trying to write a class 'STFT' to perfom a short time FT. It calls the fftw3.h functions, which output a double*[2] array, and I want to create an array of these arrays. So I thought the following would be a suitable transform function (this is a stripped down version):
void STFT::Transform(double ***transform) {
//stuff
}
However, when I called it with say
transform[100][100][2]
I get the error message:
error: cannot convert double (*)[100][2]' to `double***
After looking around, I think I've found a solution using templates Storing C++ template function definitions in a .CPP file but I'm having trouble implementing it, mainly in figuring out where I put the general type indicator 'T'. My updated functions are:
STFT.hpp
class STFT {
public:
template<int N>
void Transform(double transform[][N][2]);
};
STFT.cpp
using namespace std;
template<int N>
void STFT::Transform(double transform[][N][2]) {
cout << "IT WORKS" << endl;
}
and the function call is in main.cpp:
STFT stft;
double transform[100][100][2];
stft.Transform(transform);
However, this doesn't seem to work. The error message is:
undefined reference to `void STFT::Transform<100>(double (*) [100][2])
I imagine the problem lies in my naive implementation of templates. I've tried multiple different ways but I can't seem to get to a solution, if anyone can assist I'd be super grateful!