/*--------------------------------------------------------------------------------
入力データの読み込み
read the input data
readdata.c
*--------------------------------------------------------------------------------*/
#include "RS_surrogate.h"
double *readdata( int *num )
{
unsigned long int i;
double *data;
if ( scanf( "%d", num ) != 1 ) {
fputs( "cannot get the data number\n", stderr );
return NULL;
}
if (( data = (double*)malloc( (*num) * sizeof(double))) == NULL ){
fputs( "cannot allocate memory\n", stderr );
return NULL;
}
for ( i = 0; i < (*num); i++ ) {
if ( scanf( "%lf", &data[i] ) != 1 ) {
fputs( "cannot read data\n", stderr );
return NULL;
}
}
return data;
}