31 (*y_host) = (
double*)malloc(NUM *
NSP *
sizeof(
double));
32 (*variable_host) = (
double*)malloc(NUM *
sizeof(
double));
33 FILE *fp = fopen (filename,
"rb");
36 fprintf(stderr,
"Could not open file: %s\n", filename);
39 double buffer[
NN + 2];
42 for (
int i = 0; i < NUM; ++i)
45 int count = fread(buffer,
sizeof(
double),
NN + 2, fp);
46 if (count != (
NN + 2))
48 fprintf(stderr,
"File (%s) is incorrectly formatted, %d doubles were expected but only %d were read.\n", filename,
NN + 1, count);
54 (*y_host)[i] = buffer[1];
56 (*variable_host)[i] = buffer[2];
58 double pres = buffer[2];
60 for (
int j = 0; j <
NSP - 1; j++)
61 (*y_host)[i + (j + 1) * NUM] = buffer[j + 3];
68 for (
int j = 0; j <
NSP - 1; ++j)
70 Yi[j] = (*y_host)[i + (j + 1) * NUM];
74 (*variable_host)[i] = getDensity ((*y_host)[i], pres, Xi);
void apply_mask(double *y_host)
Not needed for van der Pol.
void read_initial_conditions(const char *filename, int NUM, double **y_host, double **variable_host)
Reads initial conditions for IVPs from binary file.