Linear Algebra and the C Language/a0j9


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00b.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
double **X_c_nr_mR(
double **A,
int r_n,
double **B
)
{
int r;
int c;

 	for    (r=R1; r<=r_n; r++)
 	   for (c=C1; c<A[C_SIZE][C0]; c++)

            B[r][c] = A[r][c];

  return(B);
}
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int r,int c)
{
double **A     = r_mR(i_mR(r,c),99.);
double **B     =      i_mR(R3,c);

  clrscrn(); 
  printf(" A:");
  p_mR(A, S5,P0,C10);   
    
  printf(" B: c_nr_mR(A,R3,B);");
  p_mR(c_nr_mR(A,C3,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+C3,i+C3);

} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Copy n rows of a matrix A into a matrix B.

Screen output example:

                                                                                       
 A:
  -58   +26   +27   +87   +61 
  +30   -90   -41   +69   +93 
  -91   +94   -78   +68   +44 
  -90   -18   +90   -48   -79 
  -37   +80   -51   +32   -10 

 B: c_nr_mR(A,R3,B);
  -58   +26   +27   +87   +61 
  +30   -90   -41   +69   +93 
  -91   +94   -78   +68   +44 


 Press   return to continue
 Press X return to stop