Aller au contenu

Mathc matrices/h23b

Un livre de Wikilivres.


Application



Installer ce fichier dans votre répertoire de travail.

dot_trac.h
/* ------------------------------------ */
/*  Save as :   dot_trac.h                */
/* ------------------------------------ */

/* ------------------------------------ */
/* ------- <A,B> = trace(A^t B) ------- */
/* ------------------------------------ */
double dot_TR_R(
double **A,
double **B
)
{
double **At    = i_mR(rsize_R(A),csize_R(A) );
double **T_AtB = i_mR(rsize_R(A),csize_R(A)  );

double trace;
  
  transpose_mR(A,At);
  
        mul_mR(At,B,T_AtB);
        
  trace = trace_mR(T_AtB);
  
  f_mR(At);
  f_mR(T_AtB);
      
  return (trace);
}
/* ------------------------------------ */
/* ------  ||u|| =  (u.u)^(1/2) ------- */
/* ------------------------------------ */
double norm_TR_R(
double **A
)
{
    return ( pow( dot_TR_R(A,A),(1./2.)) );
}
/* ------------------------------------  */
/* ------ d(u,v) = ||u-v||^(1/2) ------- */
/* ------------------------------------  */
double dist_TR_R(
double **A,
double **B
)
{
double **AmnsB  =  i_mR(rsize_R(A),csize_R(A));

double d;
  
  sub_mR(A,B,AmnsB);

/*           d(u,v) = ||u-v||^(1/2)       */

  d = norm_TR_R(AmnsB);
  
  f_mR(AmnsB);
  
  return (d);
}
/* ------------------------------------ */
/* ---- <A,B> = A^t B = B^t A --------- */
/* ------------------------------------ */
double **proj_TR_mR(
double **A,
double **B,
double **projAB
)
{
           /* <u,v>     /  ||v||^2  */
double s = dot_TR_R(A,B) / dot_TR_R(B,B);

/* (<u,v>/||v||^2) v */
    smul_mR(s,B,projAB);
    
  return(projAB); 
}
/* ------------------------------------ */
/* ------------------------------------ */
/* ------------------------------------ */


Déclaration des fichiers h.