time_det_by_minor_c

View page source

Determine Amount of Time to Execute det_by_minor

Syntax

time = time_test ( size , time_min )

Purpose

reports the amount of wall clock time for 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

The argument 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

The return value 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).

Source Code

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;
}