411 REFERENCE · Wikibooks
Linear Algebra and the C Language/a09i
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 : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define ARRAY A7
#define RCA R4
/* ------------------------------------ */
void fun(void)
{
double **A[ARRAY];
double **P[ARRAY];
double **InvP[ARRAY];
double **T = i_mR(RCA,RCA);
int i;
for(i=A0; i<ARRAY; i++)
{
A[i] = i_mR(RCA,RCA);
P[i] = r_mR( i_mR(RCA,RCA),9);
InvP[i] = inv_mR(P[i], i_mR(RCA,RCA));
}
rsymmetric_mR(A[0],99);
for(i=A0; i<(ARRAY-C1); i++)
{
mul_mR(InvP[i],A[i],T);
mul_mR(T,P[i],A[i+C1]);
}
clrscrn();
printf(" Similar matrices have the same determinant.\n\n");
for(i=A0; i<ARRAY; i++)
{
printf(" A[%d] : \t\t\t det = %+.4f ",i,det_R(A[i]));
p_mR(A[i], S9,P2,C6);
}
for(i=A0; i<ARRAY; i++)
{
f_mR(A[i]);
f_mR(P[i]);
f_mR(InvP[i]);
}
f_mR(T);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do{
fun();
}while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Similar matrices have the same determinant.
Screen output example:
Similar matrices have the same determinant.
A[0] : det = +1355628.0000
-78.00 -8.00 +84.00 -4.00
-8.00 -8.00 +38.00 +25.00
+84.00 +38.00 -62.00 -3.00
-4.00 +25.00 -3.00 -11.00
A[1] : det = +1355628.0000
-56.35 -18.10 +64.51 -49.34
-4.62 -39.10 -0.61 -33.22
+40.93 +32.44 -32.65 +45.34
-68.48 -67.13 +57.22 -30.90
A[2] : det = +1355628.0000
+280.30 +12.61 -44.60 -49.09
-2666.55 -352.86 +307.56 +164.15
-647.08 -60.76 +55.05 +63.54
+2160.58 +269.75 -213.26 -141.50
A[3] : det = +1355627.9999
+1028.53 -4704.64 -5305.74 -2283.19
-679.81 +2887.78 +3218.14 +1362.18
+2370.52 -10462.37 -11899.87 -5117.90
-3630.23 +16057.85 +18213.18 +7824.56
A[4] : det = +1355627.9991
+53087.41 -10634.98 +71630.78 -35651.49
-56258.23 +11174.43 -75854.81 +37727.23
+4363.00 -758.95 +5850.76 -2866.71
+104798.06 -20802.76 +141306.35 -70271.61
A[5] : det = +1355628.0011
+5813.35 +27387.42 -75267.10 +70731.77
+16114.04 +74151.82 -204818.55 +192003.21
-2274.14 -10094.51 +28120.54 -26248.51
-9130.70 -41778.07 +115536.06 -108244.71
A[6] : det = +1355628.0024
+86044.46 +82832.80 +124012.56 +33020.24
+206188.39 +201271.78 +299205.06 +77998.34
-224803.15 -219036.19 -325921.93 -85209.21
+102758.08 +101356.40 +149882.15 +38446.68
Press return to continue
Press X return to stop