Correctness Test of det_by_minor Routine
Keywords: correctness test det_by_minor routine syntax flag source code

| Prev | Next |  |  |  |  |  | correct_det_by_minor_c |

Correctness Test of det_by_minor Routine
Syntax
`flag = correct_det_by_minor()`
flag
The return value has prototype `
bool flag
` It value is `1` if the test passes and `0` otherwise.
Source Code `

    bool correct_det_by_minor(void)
    {    double a[9], det, check;

         random_seed(123);
         uniform_01(9, a);

         /* compute determinant using expansion by minors */
         det = det_by_minor(a, 3);

         /* use expansion by minors to hand code the determinant  */
         check = 0.;
         check += a[0] * ( a[4] * a[8] - a[5] * a[7] );
         check -= a[1] * ( a[3] * a[8] - a[5] * a[6] );
         check += a[2] * ( a[3] * a[7] - a[4] * a[6] );

         if( fabs(det / check - 1.0) < 1e-10 )
              return true;
         return false;
    }

`

Input File: compare_c/det_by_minor.c