Linear Algebra and the C Language/a083
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as: c00e.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{ /* The system is consistent */
double **Ab = r_singular_Ab_mR( i_Abr_Ac_bc_mR(r,r,C1),999);
double **A = c_Ab_A_mR(Ab, i_mR(r,r));
double **b = c_Ab_b_mR(Ab, i_mR(r,C1));
r_mR(b,999); /* I change the value of b */
c_A_b_Ab_mR(A,b,Ab); /* The system is not consistent */
clrscrn();
printf(" Ab: Rows of identical A's, with different b's");
p_mR(Ab, S8,P0,C7);
stop();
clrscrn();
printf(" Copy/Paste into the octave window.\n\n");
p_Octave_mR(Ab,"Ab",P0);
printf("\n rref(Ab,.00000000001)\n\n");
printf(" gj_PP_mR(Ab,YES):");
p_mR(gj_PP_mR(Ab,YES), S10,P4,C7);
is_system_consistent_mR(Ab);
f_mR(Ab);
f_mR(b);
f_mR(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(R5)+R1);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
Ab: Rows of identical A's, with different b's
+354 -169 -938 +155 -687 -695
-43 -478 +160 +672 +919 -873
+850 -112 +248 +446 -845 +740
+354 -169 -938 +155 -687 +431
+354 -169 -938 +155 -687 -635
Press return to continue.
Copy/Paste into the octave window.
Ab=[
+354,-169,-938,+155,-687,-695;
-43,-478,+160,+672,+919,-873;
+850,-112,+248,+446,-845,+740;
+354,-169,-938,+155,-687,+431;
+354,-169,-938,+155,-687,-635]
rref(Ab,.00000000001)
gj_PP_mR(Ab,YES):
+1.0000 +0.0000 +0.0000 +0.2889 -1.3584 +0.9196
-0.0000 +1.0000 -0.0000 -1.3682 -1.6286 +1.9879
-0.0000 -0.0000 +1.0000 +0.1903 +0.5132 +0.7298
+0.0000 +0.0000 -0.0000 +0.0000 +0.0000 +1126.0000
+0.0000 +0.0000 -0.0000 +0.0000 +0.0000 +60.0000
This(ese) row(s) are incompatible.
row 4; row 5;
The system is inconsistent.
I prefer to close the program.
Press return to continue.