Linear Algebra and the C Language/a0jb


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :   c00b.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
double **X_c_c_D_mR(
double **U,
double **D
)
{
int      r;

  m0_mR(D);
  
  for(r=R1; r<AC[R_SIZE][C0]; r++)

             D[r][r] = U[r][C1];
 return(D);
}
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int rc)
{
double **A =        r_mR(   i_mR(rc,C1),99);
double **D =    c_c_D_mR(A, i_mR(rc,rc));

  clrscrn();

  printf(" A:");
  p_mR(A, S4,P0,C8);

  printf(" D:");  
  p_mR(D, S4,P0,C8);
     
  f_mR(A);
  f_mR(D);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

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

  while(stop_w());       

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Copy a column vector into a diagonal matrix.

Screen output example:

                                                                                       
 A:
 -27 
 -47 
 +78 
 -16 
 +91 

 D:
 -27   +0   +0   +0   +0 
  +0  -47   +0   +0   +0 
  +0   +0  +78   +0   +0 
  +0   +0   +0  -16   +0 
  +0   +0   +0   +0  +91 


 Press   return to continue
 Press X return to stop