You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Friday, May 14th 2010, 7:32pm

error: invalid types ‘double __complex__[int]’ for array subscript

Hi I'm new around here, I've been working on a project on Qt and I'm mostly self-taught and also I'm no master of c++ whatsoever :S

Well I am stuck with a problem and I haven't been able to understand it. I am working on a c++ class that will be part of the Qt project, I'm using the fftw3 header so here is my code:

.h

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef FFT_H
#define FFT_H

#include <QObject>
#include <QTimer>
#include <QVector>

class fft : public QObject
{
public:
	fft();
	void changeindx();
	void estimule();
	void Nestimule();
	void dofft();
	QTimer *twosec;
	QVector <double> *select;

public slots:
	void timeout();
};

#endif // FFT_H


.cpp

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "fft.h"
#include "complex.h"
#include "math.h"
#include <fftw3.h>
#include <QTimer>

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

int indx, N;
double a, noise;

fftw_complex *in, *out;
fftw_plan p;


fft::fft()
{
N = 256;
in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
p = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_MEASURE);

twosec = new QTimer(this);
twosec->start(2000);
QObject::connect(twosec,SIGNAL(timeout()),this,SLOT(timeout()));
}


when a timeout happens it calls this part:

Source code

1
2
3
4
5
6
7
8
9
void fft::estimule()
{
for (int i = 0; i < N; ++i) {
    a = (1/128) * i;
    noise = (2*static_cast<double>(rand())/static_cast<double>(RAND_MAX))-1;
    in[i][0] = 6*sin(2*M_PI*7*a) + 3*sin(2*M_PI*14*a) + 2*sin(2*M_PI*3*a) + sin(2*M_PI*60*a) + noise;
    in[i][1] = 0.0;
}
}


I get the following error at lines 6 and 7 of the second part of the code:
error: invalid types ‘double __complex__[int]’ for array subscript

I don't understand what's wrong...

Thanks!

2

Wednesday, May 20th 2015, 3:54pm

Hi, everyone!
He-he, I'm look like a slowpoke, but now I have the same problem.
If the solution has been found, please, describe it :)