]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/numeric/odeint/performance/c_lorenz.c
5 void lorenz(const double *x
, double *restrict y
) {
6 y
[0] = 10.0 * (x
[1] - x
[0]);
7 y
[1] = 28.0 * x
[0] - x
[1] - x
[0] * x
[2];
8 y
[2] = x
[0] * x
[1] - (8.0 / 3.0) * x
[2];
11 int main(int argc
, const char *argv
[])
13 const int nb_steps
= 20000000;
14 const double h
= 1.0e-10;
15 const double h2
= 0.5 * h
;
16 const double nb_loops
= 21;
23 double min_time
= 1E6
;
27 for (int j
= 0; j
< nb_loops
; j
++) {
32 for (int k
= 0; k
< nb_steps
; k
++) {
34 for (int i
= 0; i
< 3; i
++) {
35 y
[i
] = x
[i
] + h2
* f1
[i
];
38 for (int i
= 0; i
< 3; i
++) {
39 y
[i
] = x
[i
] + h2
* f2
[i
];
42 for (int i
= 0; i
< 3; i
++) {
43 y
[i
] = x
[i
] + h
* f3
[i
];
46 for (int i
= 0; i
< 3; i
++) {
47 x
[i
] = x
[i
] + h
* (f1
[i
] + 2 * (f2
[i
] + f3
[i
]) + f4
[i
]) / 6.0;
51 min_time
= fmin(min_time
, (double)(end
-begin
)/CLOCKS_PER_SEC
);
52 printf("Result: %f\t runtime: %f\n", x
[0], (double)(end
-begin
)/CLOCKS_PER_SEC
);
54 printf("Minimal Runtime: %f\n", min_time
);