411 REFERENCE · Wikibooks
Linear Algebra and the C Language/a0pk
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 : c00g.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
double **X_c_r_c_mR(
double **A,
int rA,
double **B,
int cB
)
{
int rc;
for(rc=RC1; rc<A[R_SIZE][C0]; rc++)
B[rc][cB] = A[rA][rc];
return(B);
}
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int r)
{
double **A = r_mR( i_mR(r,r),99);
double **B = i_mR(r,r);
clrscrn();
printf(" A:");
p_mR(A, S5,P0,C10);
printf(" B: Copy the row R1 of A into the column C3 of B");
c_r_c_mR(A,R1,B,C3);
p_mR(B, S5,P0,C10);
f_mR(A);
f_mR(B);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
/* int i; */
do
{
/* i = rp_I(R3)+R1; */
fun(R4);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Copy a row of matrix A into a column of matrix B:
Screen output example:
A:
-93 -57 +35 +36
+57 +72 -9 +77
-98 -75 +97 -23
-42 -14 -94 +3
B: Copy the row R1 of A into the column C3 of B
+0 +0 -93 +0
+0 +0 -57 +0
+0 +0 +35 +0
+0 +0 +36 +0
Press return to continue
Press X return to stop