Linear Algebra and the C Language/a0hk


In linear algebra, a circulant matrix is a square matrix in which all rows are composed of the same elements and each row is rotated one element to the right relative to the preceding row. It is a particular kind of Toeplitz matrix.... Wikipedia: Circulant matrix


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00f.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define   RC  RC6
/* ------------------------------------ */
int main(void)
{
/* Toeplitz Matrix 
   
        V
 
   U    1 5 6 7
        2 
        3         
        4
     
  */
  
double u[R1*RC]={ 1,2,3,4,5,6};
double v[RC*C1]={ 1,
	              6,
	              5,
	              4,
	              3,
	              2};
	              	                 
double **V   = ca_A_mR(v,i_mR(RC,C1));	
double **U   = ca_A_mR(u,i_mR(R1,RC));
double **A   =           i_mR(RC,RC);

  clrscrn();
  
  rToeplitz_mR(U,V,A);

  printf(" In linear algebra, a circulant  matrix is\n"
         "​​ a square matrix in which the coefficients\n"
         "​​ are  moved  from  one row  to the next by\n"
         " ​​circular permutation (right shift).  \n\n\n");
    
  printf(" A: Circulating matrix");
  p_mR(A, S4,P0,C10);
  stop();

  f_mR(U);
  f_mR(V);   
  f_mR(A);
  
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


Screen output example:

                                                                                       
 In linear algebra, a circulant  matrix is
 a square matrix in which the coefficients
 are  moved  from  one row  to the next by
 ​​circular permutation (right shift).  


 A: Circulating matrix
  +1   +2   +3   +4   +5   +6 
  +6   +1   +2   +3   +4   +5 
  +5   +6   +1   +2   +3   +4 
  +4   +5   +6   +1   +2   +3 
  +3   +4   +5   +6   +1   +2 
  +2   +3   +4   +5   +6   +1 

 Press return to continue.