Linear Algebra and the C Language/a052
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : swapr.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
int main(void)
{
double a[R3*C3] = { 1, 1, 1,
2, 2, 2,
3, 3, 3};
double **A = ca_A_mR(a,i_mR(R3,C3));
int r1 = R1;
int r2 = R3;
clrscrn();
printf(" A :");
p_mR(A,S5,P0,C6);
printf(" swapR_mR(A, R%d, R%d)\n\n",r1,r2);
printf(" A :");
p_mR(swapR_mR(A,r1,r2),S5,P0,C6);
f_mR(A);
stop();
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Swaps two lines:
Screen output example:
A :
+1 +1 +1
+2 +2 +2
+3 +3 +3
swapR_mR(A, R1, R3)
A :
+3 +3 +3
+2 +2 +2
+1 +1 +1
Press return to continue.