411 REFERENCE · Wikibooks
Linear Algebra and the C Language/a0nn
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: c00b.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int rc)
{
double **A = r_mR( i_mR(rc,rc),99);
double **At = transpose_mR(A, i_mR(rc,rc));
double **AplsAt = add_mR(A,At, i_mR(rc,rc));
clrscrn();
printf(" A[R%d,C%d]: \n",rsize_R(A),csize_R(A));
p_mR(A, S4,P0, C4);
printf(" At[R%d,C%d]: Transpose\n",
rsize_R(At),csize_R(At));
p_mR(At, S4,P0, C4);
printf(" (A + At)[R%d,C%d]: \n",rsize_R(AplsAt),csize_R(AplsAt));
p_mR(AplsAt, S7,P0, C4);
f_mR(A);
f_mR(At);
f_mR(AplsAt);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
fun(RC4);
while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Adding a square matrix A to its transpose gives a symmetric matrix
Screen output example:
A[R4,C4]:
-31 -67 +94 -12
+1 +55 +3 +1
-52 +60 -26 +94
+98 -69 -87 -54
At[R4,C4]: Transpose
-31 +1 -52 +98
-67 +55 +60 -69
+94 +3 -26 -87
-12 +1 +94 -54
(A + At)[R4,C4]:
-62 -66 +42 +86
-66 +110 +63 -68
+42 +63 -52 +7
+86 -68 +7 -108
Press return to continue
Press X return to stop