Linear Algebra and the C Language/a0hy


Install and compile this file in your working directory.

/* ------------------------------------ */
/*  Save as :  c00f.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A         = rupper_mR(i_mR(r,r),999.);
double **EigsVector=           i_mR(r,r);
double **EigsValue =           i_mR(r,C1);

  clrscrn();
  printf(" Copy/Paste into the octave windows \n\n");
  p_Octave_mR(A,"a",P0);
  printf(" [V, E] = eigs (a,%d) \n\n",r);
  stop();

  clrscrn();   
  printf(" A:");
  p_mR(A ,S5,P0,C6);  
  
  eigs_V_mR(A,EigsVector); 
  printf(" EigsVector:");
  p_mR(EigsVector ,S5,P4,C6);
   
  eigs_mR(A,EigsValue);
  printf(" EigsValue:");
  p_mR(EigsValue ,S13,P4,C1);   
   
  f_mR(A);
  f_mR(EigsVector);
  f_mR(EigsValue);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
 fun(rp_I(R3)+R2);

} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
* Eigenvalues and ​​eigenvectors of a upper triangular matrix
* I check that the eigenvalues ​​of the upper triangular matrix 
  A correspond to the values ​​found on the diagonal.
  They can be in a different order.

Screen output example:

                                                                                       
 Copy/Paste into the octave windows 

 a=[
-75,-700,+904,+697,-245;
+0,+125,+914,+914,+659;
+0,+0,-160,-687,-702;
+0,+0,+0,+108,+812;
+0,+0,+0,+0,+138]

 [V, E] = eigs (a,5) 

 Press return to continue. 


 A:
  -75  -700  +904  +697  -245 
   +0  +125  +914  +914  +659 
   +0    +0  -160  -687  -702 
   +0    +0    +0  +108  +812 
   +0    +0    +0    +0  +138 

 EigsVector:
+1.0000 +0.9615 +0.9959 +0.9691 +0.9548 
+0.0000 -0.2747 +0.0862 -0.2466 -0.2971 
+0.0000 -0.0000 -0.0269 +0.0075 -0.0074 
+0.0000 +0.0000 +0.0000 -0.0029 +0.0031 
+0.0000 +0.0000 +0.0000 +0.0000 +0.0001 

 EigsValue:
     -75.0000 
    +125.0000 
    -160.0000 
    +108.0000 
    +138.0000 


 Press   return to continue
 Press X return to stop