76 int number_of_lines = 0;
78 if ( (
argc < 2 ) || ( fr = fopen(
argv[1],
"r" ) ) == NULL )
80 fprintf( stderr,
"Cannot open first file as readable\n" );
84 if ( (
argc < 3 ) || ( fw = fopen(
argv[2],
"w" ) ) == NULL )
86 fprintf( stderr,
"Cannot open second file as writable\n" );
94 while ( ( fgets( readbuffer, 255, fr ) != NULL ) )
103 if ( (
xspline = (
double *) calloc( (
size_t) number_of_lines, (
size_t)
sizeof (
double ) ) ) == NULL )
104 MemError1(
"Allocating memory to the xspline table" );
106 if ( (
yspline = (
double *) calloc( (
size_t) number_of_lines, (
size_t)
sizeof (
double ) ) ) == NULL )
107 MemError1(
"Allocating memory to the yspline table" );
109 if ( (
y2spline = (
double *) calloc( (
size_t) number_of_lines, (
size_t)
sizeof (
double ) ) ) == NULL )
110 MemError1(
"Allocating memory to the y2spline table" );
118 while ( ( fgets( readbuffer, 255, fr ) != NULL ) )
120 sscanf( readbuffer,
"%lf %lf", (
double *) &
xspline[i], (
double *) &
yspline[i] );
136 fprintf( fw,
"%s\n",
header );
138 fprintf( fw,
"const int number_of_entries_in_spline_tables=%d;\n\n", number_of_lines );
140 fprintf( fw,
"const double xspline[%d] = {\n", number_of_lines );
141 for ( i = 0; i < number_of_lines; i++ )
143 fprintf( fw,
"%10.0f,\n",
xspline[i] );
145 fprintf( fw,
"};\n" );
147 fprintf( fw,
"const double yspline[%d] = {\n", number_of_lines );
148 for ( i = 0; i < number_of_lines; i++ )
150 fprintf( fw,
"%10.0f,\n",
yspline[i] );
152 fprintf( fw,
"};\n" );
154 fprintf( fw,
"const double y2spline[%d] = {\n", number_of_lines );
155 for ( i = 0; i < number_of_lines; i++ )
157 fprintf( fw,
"%25.15e,\n",
y2spline[i] );
159 fprintf( fw,
"};\n" );
int dspline(double *x, double *y, int n, int if1, double cond1, int ifn, double condn, double *y2)