/*--------------------------------------------------------------------------------
入力データの読み込み
read the input data
readdata.c
*--------------------------------------------------------------------------------*/
#include "FFT.h"
complex *readdata( int *num )
{
int t;
complex *x;
if ( scanf( "%d", num ) != 1 ) {
fputs( "cannot get the data number\n", stderr );
return NULL;
}
if ( ( x = (complex *)malloc( (*num) * sizeof(complex) ) ) == NULL ) {
fputs( "cannot allocate memory\n", stderr );
return NULL;
}
// 実データには虚部が存在しないので、読み込んだ値はx[t].real に入力し、
// x[t].imag にはゼロを入力
// As there is no imaginary part in real data, input the read value to x[t].real,
// and input zero to x[t].imag
for ( t = 0; t < (*num); t++ ) {
if ( scanf( "%lf", &x[t].real ) != 1 ) {
fputs( "cannot read the data\n", stderr );
return NULL;
}
x[t].imag = 0.0;
}
return x;
}