update: pass pointers into init()
This commit is contained in:
11
src/init.c
11
src/init.c
@@ -132,7 +132,9 @@ static void refine_interval(double xl, double xr, double yl, double yr, double r
|
||||
return ;
|
||||
}
|
||||
|
||||
int init(double bmax, double rela_err_limit){
|
||||
int init(double bmax, double rela_err_limit, int *size, double *x, double *y){
|
||||
if (x) free(x);
|
||||
if (y) free(y);
|
||||
SampleData sample;
|
||||
sample.capacity = 1;
|
||||
sample.size=1;
|
||||
@@ -151,8 +153,13 @@ int init(double bmax, double rela_err_limit){
|
||||
//output
|
||||
//printf("Total sample points capacity: %d\n", sample.capacity);
|
||||
//printf("Total sample points number: %d\n", sample.size);
|
||||
*size = sample.size;
|
||||
x = malloc(sizeof(double) * sample.size);
|
||||
y = malloc(sizeof(double) * sample.size);
|
||||
for (int i = 0; i < sample.size; i++) {
|
||||
printf("%.16g %.16g\n", sample.x[i], sample.y[i]);
|
||||
//printf("%.16g %.16g\n", sample.x[i], sample.y[i]);
|
||||
x[i] = sample.x[i];
|
||||
y[i] = sample.y[i];
|
||||
}
|
||||
|
||||
free(sample.x);
|
||||
|
||||
Reference in New Issue
Block a user