Linear Algebra and the C Language/a0bs
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00c.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A = r_Q_mR( i_mR(r,r), 9);
double **B = r_Q_mR( i_mR(r,r), 9);
double **AB = mul_mR(A,B, i_mR(r,r));
double **ABT = transpose_mR(AB, i_mR(r,r));
double **T = mul_mR(AB,ABT, i_mR(r,r));
clrscrn();
printf(" A: an orthonormal matrix ");
p_mR(A,S3,P3,C6);
printf(" B: an orthonormal matrix ");
p_mR(B,S3,P3,C6);
stop();
clrscrn();
printf(" A B = AB AB is an orthonormal matrix");
p_mR(AB,S3,P3,C6);
printf(" AB ABT = id inv(AB) = ABT ");
p_mR(T,S3,P3,C6);
f_mR(A);
f_mR(B);
f_mR(AB);
f_mR(ABT);
f_mR(T);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(R3) + R2);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
A: an orthonormal matrix
-0.331 -0.915 +0.230
+0.579 -0.004 +0.815
-0.745 +0.403 +0.532
B: an orthonormal matrix
+0.811 -0.479 -0.336
+0.487 +0.871 -0.067
+0.324 -0.109 +0.940
Press return to continue.
A B = AB AB is an orthonormal matrix
-0.639 -0.664 +0.389
+0.732 -0.370 +0.572
-0.235 +0.650 +0.722
AB ABT = id inv(AB) = ABT
+1.000 -0.000 +0.000
-0.000 +1.000 +0.000
+0.000 +0.000 +1.000
Press return to continue
Press X return to stop