mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
added timing for durand_kramer
This commit is contained in:
parent
205bcdd9a1
commit
1cd50024b5
@ -5,6 +5,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <complex.h>
|
#include <complex.h>
|
||||||
|
#include "function_timer.h"
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Try the highly unstable Wilkinson's polynomial:
|
* Try the highly unstable Wilkinson's polynomial:
|
||||||
@ -131,8 +132,11 @@ int main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
double tol_condition = 1;
|
double tol_condition = 1;
|
||||||
|
double dtime;
|
||||||
unsigned long iter = 0;
|
unsigned long iter = 0;
|
||||||
|
|
||||||
|
function_timer *timer = new_timer();
|
||||||
|
start_timer(timer);
|
||||||
while (!check_termination(tol_condition) && iter < INT_MAX)
|
while (!check_termination(tol_condition) && iter < INT_MAX)
|
||||||
{
|
{
|
||||||
long double complex delta = 0;
|
long double complex delta = 0;
|
||||||
@ -181,9 +185,10 @@ int main(int argc, char **argv)
|
|||||||
fprintf(log_file, "%.4g", tol_condition);
|
fprintf(log_file, "%.4g", tol_condition);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
|
||||||
|
dtime = end_timer(timer);
|
||||||
|
|
||||||
#if defined(DEBUG) || !defined(NDEBUG)
|
#if defined(DEBUG) || !defined(NDEBUG)
|
||||||
fclose(log_file);
|
fclose(log_file);
|
||||||
#endif
|
#endif
|
||||||
@ -192,6 +197,7 @@ end:
|
|||||||
for (n = 0; n < degree - 1; n++)
|
for (n = 0; n < degree - 1; n++)
|
||||||
printf("\t%s\n", complex_str(s0[n]));
|
printf("\t%s\n", complex_str(s0[n]));
|
||||||
printf("absolute average change: %.4g\n", tol_condition);
|
printf("absolute average change: %.4g\n", tol_condition);
|
||||||
|
printf("Time taken: %.4g sec\n", dtime);
|
||||||
|
|
||||||
free(coeffs);
|
free(coeffs);
|
||||||
free(s0);
|
free(s0);
|
||||||
|
Loading…
Reference in New Issue
Block a user