Linear Algebra and the C Language/a04v
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00d.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A = r_mR( i_mR(r,r),9);
double **A_adjoint = adjoint_mR(A, i_mR(r,r) );
double **B = r_mR( i_mR(r,r),9);
double **B_adjoint = adjoint_mR(B, i_mR(r,r) );
double **AB = mul_mR(A,B, i_mR(r,r) );
double **AB_adjoint = adjoint_mR(AB, i_mR(r,r) );
double **B_adjointA_adjoint = mul_mR(B_adjoint,A_adjoint,i_mR(r,r));
clrscrn();
printf(" A :");
p_mR(A,S3,P0,C6);
printf(" B :");
p_mR(B,S3,P0,C6);
stop();
clrscrn();
printf(" adjoint(A) :");
p_mR(A_adjoint,S6,P0,C6);
printf(" adjoint(B) :");
p_mR(B_adjoint,S6,P0,C6);
stop();
clrscrn();
printf(" adjoint(AB) :");
p_mR(AB_adjoint,S10,P0,C6);
printf(" adjoint(B) * adjoint(A) :");
p_mR(B_adjointA_adjoint,S10,P0,C6);
f_mR(A);
f_mR(A_adjoint);
f_mR(B);
f_mR(B_adjoint);
f_mR(AB);
f_mR(AB_adjoint);
f_mR(B_adjointA_adjoint);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(RC4)+C1);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
A :
+3 +8 +8
+2 +5 -7
+8 +4 -9
B :
-4 -1 -8
+3 +2 -2
-4 -1 +8
Press return to continue.
adjoint(A) :
-17 +104 -96
-38 -91 +37
-32 +52 -1
adjoint(B) :
+14 +16 +18
-16 -64 -32
+5 +0 -5
Press return to continue.
adjoint(AB) :
-1422 +936 -770
+3728 +2496 -800
+75 +260 -475
adjoint(B) * adjoint(A) :
-1422 +936 -770
+3728 +2496 -800
+75 +260 -475
Press return to continue
Press X return to stop