Linear Algebra and the C Language/a0gx
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
double **X_rcentrosymmetric_mR(
double **A,
int k)
{
int r;
int c;
int n = rsize_R(A);
double x;
isquare_mR(A,"rcentrosymmetric_mR();","(A)");
for ( r=R1; r<A[R_SIZE][C0]; r++)
for ( c=C1; c<A[C_SIZE][C0]; c++)
{
x = r_I(k);
A[n-r+1][n-c+1] = x;
A[r ][c ] = x;
}
return(A);
}
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int r)
{
double **A = rcentrosymmetric_mR(i_mR(r,r),999.);
clrscrn();
printf(" A: Centrosymmetric matrix");
p_mR(A, S5,P0,C7);
f_mR(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun( rp_I(RC3)*2 + RC1);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
A: Centrosymmetric matrix
-816 +186 +795 -851 +554
-285 -590 -791 +218 +675
-361 -794 +142 -794 -361
+675 +218 -791 -590 -285
+554 -851 +795 +186 -816
Press return to continue
Press X return to stop