Linear Algebra and the C Language/a0j5


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00f.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
double  **X_c_c_r_mR(
double **A,
int cA,
double **B,
int rB
)
{
int rc;

    for(rc=RC1; rc<A[R_SIZE][C0]; rc++)

            B[rB][rc] = A[rc][cA];
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: c_c_r_mR(A,C1,B,R2);");
  c_c_r_mR(A,C1,B,R2);
  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(i);

} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Copy a column of matrix A into a row of matrix B:

Screen output example:

                                                                                       
 A:
  -69   -21   +49   -64 
   -7   +24   -89   -66 
   -5   -69    -7   -40 
  +68   -13   +27   +94 

 B: c_c_r_mR(A,C1,B,R2);
   +0    +0    +0    +0 
  -69    -7    -5   +68 
   +0    +0    +0    +0 
   +0    +0    +0    +0 


 Press   return to continue
 Press X return to stop