-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathListing8.c
More file actions
32 lines (27 loc) · 852 Bytes
/
Listing8.c
File metadata and controls
32 lines (27 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <math.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
struct point{
double *x, *y, *z;
};
struct point cell;
cell.x = (double *)malloc(1000*sizeof(double));
cell.y = (double *)malloc(1000*sizeof(double));
cell.z = (double *)malloc(1000*sizeof(double));
double *radius = (double *)malloc(1000*sizeof(double));
double *density = (double *)malloc(1000*sizeof(double));
double *density_gradient = (double *)malloc(1000*sizeof(double));
for (int i=0; i < 1000; i++){
radius[i] = sqrt(cell.x[i]*cell.x[i] + cell.y[i]*cell.y[i] + cell.z[i]*cell.z[i]);
}
for (int i=1; i < 1000; i++){
density_gradient[i] = (density[i] - density[i-1])/(cell.x[i] - cell.x[i-1]);
}
free(cell.x);
free(cell.y);
free(cell.z);
free(radius);
free(density);
free(density_gradient);
}