Linear Algebra and the C Language/a0hm


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :      c00a.c               */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */ 
/* ------------------------------------ */
double **X_rToeplitz_mR(
double **U,
double **V,
double **A
)
{
int cn = C2;
int r  = R2;

int rn = R2;
int c  = C2;

  isquare_mR(A,"rToeplitz_mR;","(A)");

  c_r_mR(U,R1,A,R1);
  c_c_mR(V,C1,A,C1);

  for(cn = C2; r <A[R_SIZE][C0]; cn++,r++)   

      c_rU_rA_cn_mR(U,R1,A,r,cn);  
      
      
  for(rn = R2; c <A[C_SIZE][C0]; rn++,c++)  
       
      c_cV_cA_rn_mR(V,C1,A,c,rn); 
          
 return(A);
}
/* ------------------------------------ */ 
/* ------------------------------------ */  
void fun(int rc)
{
double **U   = r_mR(i_mR(R1,rc),9);
double **V   = r_mR(i_mR(rc,C1),9);	
double **A   =      i_mR(rc,rc);

  c_s_mR(U[R1][C1], V,R1,C1);
  
  clrscrn();
  
  rToeplitz_mR(U,V,A);
  
  printf(" A: Toeplitz matrix");
  p_mR(A, S4,P0,C10);

  f_mR(U);
  f_mR(V);   
  f_mR(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));
  
  do
        fun(R6);

  while(stop_w());       

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


Screen output example:

                                                                                       
 A: Toeplitz matrix
  +7   +7   -9   +8   -9   -6 
  -5   +7   +7   -9   +8   -9 
  -9   -5   +7   +7   -9   +8 
  +6   -9   -5   +7   +7   -9 
  -6   +6   -9   -5   +7   +7 
  -4   -6   +6   -9   -5   +7 


 Press   return to continue
 Press X return to stop