mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
remove timing calculation
This commit is contained in:
parent
eb84d85b20
commit
b12ac414d2
@ -5,7 +5,6 @@
|
|||||||
#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:
|
||||||
@ -132,11 +131,8 @@ 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;
|
||||||
@ -187,8 +183,6 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
|
|
||||||
dtime = end_timer_delete(timer);
|
|
||||||
|
|
||||||
#if defined(DEBUG) || !defined(NDEBUG)
|
#if defined(DEBUG) || !defined(NDEBUG)
|
||||||
fclose(log_file);
|
fclose(log_file);
|
||||||
#endif
|
#endif
|
||||||
@ -197,7 +191,6 @@ 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);
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <function_timer.h>
|
|
||||||
|
|
||||||
#define ROWS 4
|
#define ROWS 4
|
||||||
#define COLUMNS 3
|
#define COLUMNS 3
|
||||||
|
|
||||||
double A[ROWS][COLUMNS] = {
|
double A[ROWS][COLUMNS] = {
|
||||||
{-3.44827586, -1.62068966, -3.03448276},
|
{1, 2, 3},
|
||||||
{-1.03448276, -0.5862069, -1.31034483},
|
{3, 6, 5},
|
||||||
{-1.55172414, -0.37931034, 0.03448276}};
|
{5, 2, 8},
|
||||||
|
{8, 9, 3}};
|
||||||
|
|
||||||
void print_matrix(double A[][COLUMNS], int M, int N)
|
void print_matrix(double A[][COLUMNS], int M, int N)
|
||||||
{
|
{
|
||||||
@ -137,14 +137,10 @@ int main(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function_timer *t1 = new_timer();
|
|
||||||
start_timer(t1);
|
|
||||||
qr_decompose(A, Q, R, ROWS, COLUMNS);
|
qr_decompose(A, Q, R, ROWS, COLUMNS);
|
||||||
double dtime = end_timer_delete(t1);
|
|
||||||
|
|
||||||
print_2d(R, ROWS, COLUMNS);
|
print_2d(R, ROWS, COLUMNS);
|
||||||
print_2d(Q, ROWS, COLUMNS);
|
print_2d(Q, ROWS, COLUMNS);
|
||||||
printf("Time taken to compute: %.4g sec\n", dtime);
|
|
||||||
|
|
||||||
for (int i = 0; i < ROWS; i++)
|
for (int i = 0; i < ROWS; i++)
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <function_timer.h>
|
|
||||||
|
|
||||||
#define LIMS 9
|
#define LIMS 9
|
||||||
|
|
||||||
@ -169,8 +168,6 @@ int main(int argc, char **argv)
|
|||||||
int counter = 0, num_eigs = rows - 1;
|
int counter = 0, num_eigs = rows - 1;
|
||||||
double last_eig = 0;
|
double last_eig = 0;
|
||||||
|
|
||||||
function_timer *t1 = new_timer();
|
|
||||||
start_timer(t1);
|
|
||||||
while (num_eigs > 0)
|
while (num_eigs > 0)
|
||||||
{
|
{
|
||||||
while (fabs(A[num_eigs][num_eigs - 1]) > 1e-10)
|
while (fabs(A[num_eigs][num_eigs - 1]) > 1e-10)
|
||||||
@ -202,7 +199,6 @@ int main(int argc, char **argv)
|
|||||||
columns--;
|
columns--;
|
||||||
}
|
}
|
||||||
eigen_vals[0] = A[0][0];
|
eigen_vals[0] = A[0][0];
|
||||||
double dtime = end_timer_delete(t1);
|
|
||||||
|
|
||||||
#if defined(DEBUG) || !defined(NDEBUG)
|
#if defined(DEBUG) || !defined(NDEBUG)
|
||||||
print_matrix(R, mat_size, mat_size);
|
print_matrix(R, mat_size, mat_size);
|
||||||
@ -211,7 +207,6 @@ int main(int argc, char **argv)
|
|||||||
printf("Eigen vals: ");
|
printf("Eigen vals: ");
|
||||||
for (i = 0; i < mat_size; i++)
|
for (i = 0; i < mat_size; i++)
|
||||||
printf("% 9.4g\t", eigen_vals[i]);
|
printf("% 9.4g\t", eigen_vals[i]);
|
||||||
printf("\nTime taken to compute: % .4g sec\n", dtime);
|
|
||||||
|
|
||||||
for (int i = 0; i < mat_size; i++)
|
for (int i = 0; i < mat_size; i++)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user