![]() |
Prev | Next | time_det_by_minor_c |
time = time_test(size, time_min)
det_by_minor
to compute the determinant of a square matrix.
The
size
has prototype
size_t size
It specifies the number of rows (and columns) in the square matrix
that the determinant is being calculated for.
time_min
has prototype
double time_min
It specifies the minimum amount of time in seconds
that the
test
routine should take.
The calculations is repeated the necessary number of times so that
this amount of execution time (or more) is reached.
time
has prototype
double time
and is the number of wall clock seconds that it took for
det_by_minor
to compute its determinant
(plus overhead which includes choosing a random matrix).
double time_det_by_minor(size_t size, double time_min) { size_t repeat; double s0, s1, time; repeat = 0; s0 = elapsed_seconds(); s1 = s0; while( s1 - s0 < time_min ) { if( repeat == 0 ) repeat = 1; else repeat = 2 * repeat; s0 = elapsed_seconds(); repeat_det_by_minor(repeat, size); s1 = elapsed_seconds(); } time = (s1 - s0) / (double) repeat; return time; }