Linear Algebra and the C Language/a0gw
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00d.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int rc)
{
double **A = rcentrosymmetric_mR( i_mR(rc,rc),9.);
double **invA = i_mR(rc,rc);
double **AinvA = i_mR(rc,rc);
clrscrn();
printf(" A:");
p_mR(A, S4,P0,C6);
printf(" invA:");
p_mR(inv_mR(A,invA), S4,P5,C6);
printf(" A * invA:");
p_mR(mul_mR(A,invA,AinvA), S4,P5,C6);
f_mR(A);
f_mR(invA);
f_mR(AinvA);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
fun(rp_I(RC2)*RC2 + RC1);
while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
The inverse of a centrosymmetric matrix is a centrosymmetric matrix
Screen output example:
A:
-2 +7 -4 -3 +4
-9 -9 +9 -1 -4
+6 +4 +2 +4 +6
-4 -1 +9 -9 -9
+4 -3 -4 +7 -2
invA:
-0.20054 -0.12046 -0.01389 -0.01842 -0.11891
+0.25815 +0.05967 +0.11806 +0.12089 +0.20713
+0.02778 +0.05556 +0.11111 +0.05556 +0.02778
+0.20713 +0.12089 +0.11806 +0.05967 +0.25815
-0.11891 -0.01842 -0.01389 -0.12046 -0.20054
A * invA:
+1.00000 +0.00000 +0.00000 +0.00000 +0.00000
-0.00000 +1.00000 -0.00000 +0.00000 -0.00000
-0.00000 +0.00000 +1.00000 +0.00000 +0.00000
+0.00000 -0.00000 +0.00000 +1.00000 -0.00000
-0.00000 +0.00000 -0.00000 -0.00000 +1.00000
Press return to continue
Press X return to stop