Linear Algebra and the C Language/a05e
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : cof_r.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int n)
{
double **A = r_mR(i_mR(n,n),99.);
int r = rp_I(n);
int c = rp_I(n);
clrscrn();
printf(" A :");
p_mR(A,S5,P0,C6);
printf(" minor(R%d,C%d) = %+.3f\n"
" cofactor(R%d,C%d) = %+.3f\n\n\n",
r,c, minor_R(A, r,c),
r,c, cofactor_R(A, r,c));
printf(" cofactor(R%d,C%d) = minor(R%d,C%d)*(-1**(R%d+C%d))\n"
" = minor(R%d,C%d)*(%0.0f)\n",
r,c, r,c, r,c, r,c, pow(-1,(r+c)));
f_mR(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(RC5)+C1);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
A :
+22 -6
+79 +92
minor(R1,C1) = +92.000
cofactor(R1,C1) = +92.000
cofactor(R1,C1) = minor(R1,C1)*(-1**(R1+C1))
= minor(R1,C1)*(1)
Press return to continue
Press X return to stop