Linear Algebra and the C Language/a0ox


Choose your eigenvalues

Introduce the values for the eigenvalues on the diagonal

/* ------------------------------------ */ 
double d[RCA*RCA] ={   
  +1, +0,   +0,  +0,   +0,   +0,
  +0, +1,   +0,  +0,   +0,   +0,       
  +0, +0,   +1,  +0,   +0,   +0, 
  +0, +0,   +0,  +1,   +0,   +0, 
  +0, +0,   +0,  +0,   +1,   +0, 
  +0, +0,   +0,  +0,   +0,   +0          
};

double **D      =         ca_A_mR(d, i_mR(RCA,RCA));        
/* ------------------------------------ */

With this function you can choose the values of your eigenvalues.

/* ------------------------------------ */
double **rdefpos_diag_mR(
double **D,                                    /* Choose your eigenvalues         */
double **A,
int      n                                     /* Control the function: r_Q_mR(); */   
)
{
int r = rsize_R(A);

double **Q    =   r_Q_mR(     i_mR(r,r),n);      /* You create an orthogonal matrix. */
double **invQ = invgj_mR(Q,   i_mR(r,r));        /* You take its inverse.            */
double **QD   =   mul_mR(Q,D, i_mR(r,r));        /* You compute:  A = Q D invQ       */

/*                    A = Q D invQ */
         mul_mR(QD,invQ,A);

  f_mR(Q);
  f_mR(invQ);
  f_mR(QD);
  
 return(A);
}
/* ------------------------------------ */


Application

You can choose the values of the eigenvalues with the function: rdefpos_diag_mR();

Let's check the result

An example: