411 REFERENCE · Wikibooks
Linear Algebra and the C Language/a0nm
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
__NOTOC__
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as: c00c.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int rc)
{
double **A = r_mR( i_mR(rc,rc),9);
double **invA = inv_mR(A, i_mR(rc,rc));
double **At = transpose_mR(A, i_mR(rc,rc));
double **invAt = inv_mR(At, i_mR(rc,rc));
double **IDE = i_mR(rc,rc);
clrscrn();
printf(" A: ");
p_mR(A, S4,P4, C6);
printf(" invA: ");
p_mR(invA, S4,P4, C6);
printf(" A * invA: ");
p_mR(mul_mR(A,invA,IDE), S4,P4, C6);
stop();
clrscrn();
printf(" At: Transpose");
p_mR(At, S4,P4, C6);
printf(" invAt: ");
p_mR(invAt, S4,P4, C6);
printf(" At * invAt: ");
p_mR(mul_mR(At,invAt,IDE), S4,P4, C6);
stop();
clrscrn();
printf(" invA: ");
p_mR(invA, S4,P4, C6);
printf(" invAt: ");
p_mR(invAt, S4,P4, C6);
f_mR(A);
f_mR(invA);
f_mR(At);
f_mR(invAt);
f_mR(IDE);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
fun(rp_I(RC3)+RC1);
while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
The inverse of the transpose of A is the transpose of the inverse of A
Screen output example:
A:
-1.0000 -4.0000 -5.0000
+1.0000 -3.0000 +3.0000
-9.0000 +4.0000 -9.0000
invA:
+0.0872 -0.3256 -0.1570
-0.1047 -0.2093 -0.0116
-0.1337 +0.2326 +0.0407
A * invA:
+1.0000 +0.0000 +0.0000
+0.0000 +1.0000 -0.0000
+0.0000 +0.0000 +1.0000
Press return to continue.
At: Transpose
-1.0000 +1.0000 -9.0000
-4.0000 -3.0000 +4.0000
-5.0000 +3.0000 -9.0000
invAt:
+0.0872 -0.1047 -0.1337
-0.3256 -0.2093 +0.2326
-0.1570 -0.0116 +0.0407
At * invAt:
+1.0000 -0.0000 +0.0000
-0.0000 +1.0000 -0.0000
+0.0000 -0.0000 +1.0000
Press return to continue.
invA:
+0.0872 -0.3256 -0.1570
-0.1047 -0.2093 -0.0116
-0.1337 +0.2326 +0.0407
invAt:
+0.0872 -0.1047 -0.1337
-0.3256 -0.2093 +0.2326
-0.1570 -0.0116 +0.0407
Press return to continue
Press X return to stop