Linear Algebra and the C Language/a06v
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00g.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A = r_mR(i_mR(r,r),9.);
double **B = i_mR(r,r);
int c1 = rp_I(A[C_SIZE][C0]-C1);
int c2 = rp_I(A[C_SIZE][C0]-C1);
clrscrn();
printf(" A:");
p_mR(A,S3,P0,C6);
printf(" B:");
p_mR(swapC_mR(c_mR(A,B),c1,c2),S3,P0,C6);
printf(" If B is the matrix that results when \n");
printf(" two columns (c[%d],c[%d]) are interchanged\n",c1,c2);
printf(" then : det(B) = - det(A)\n\n\n");
printf(" det_R(A) = %+.0f\n", det_R(A));
printf(" det_R(B) = %+.0f\n", det_R(B));
f_mR(A);
f_mR(B);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(RC4)+RC1);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
A:
-2 +6 -3
+4 +8 -2
-8 +1 -6
B:
+6 -2 -3
+8 +4 -2
+1 -8 -6
If B is the matrix that results when
two columns (c[1],c[2]) are interchanged
then : det(B) = - det(A)
det_R(A) = +128
det_R(B) = -128
Press return to continue
Press X return to stop