Linear Algebra and the C Language/a0i2
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00c.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A = rskewsymmetric_mR( i_mR(r,r), 9);
double **invA = inv_mR(A, i_mR(r,r));
clrscrn();
printf(" If Rn is even det_R(A)>0\n\n"
" det_R(A) = %+.4f\n\n\n",det_R(A));
printf(" A:");
p_mR(A, S7,P3,C6);
printf(" invA:");
p_mR(invA, S7,P3,C6);
f_mR(A);
f_mR(invA);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(R2)*R2);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
If the number of rows is even, the determinant is positive and we can calculate the inverse
Screen output example:
If Rn is even det_R(A)>0
det_R(A) = +1.0000
A:
+0.000 -9.000 +1.000 -8.000
+9.000 +0.000 -4.000 +4.000
-1.000 +4.000 +0.000 +3.000
+8.000 -4.000 -3.000 +0.000
invA:
+0.000 -3.000 +4.000 +4.000
+3.000 +0.000 +8.000 +1.000
-4.000 -8.000 +0.000 +9.000
-4.000 -1.000 -9.000 +0.000
Press return to continue
Press X return to stop