|  Home 
  
   Install 
  
   Use 
  
   Develop 
  
   Support 
  
   News 
 
 Credits
 
 hosted by
 
   | 
   15#include "Quaternion.h"    18T norm (T x) { return  fabs(x); }    24template <typename  T, typename  U>    25void calculate_Jacobi (const  U& p, const  U& q, const  T& pq,    26                       T& s, T& tau, U& correction)    29  T g = 100.0 * fabs(pq);    33  if (fabs(h)+g == fabs(h))    43    t=1.0/(fabs(theta)+sqrt(1.0+theta*theta));    44    if (theta < 0.0) t = -t;    63template <typename  T, typename  U>    64void calculate_Jacobi (const  U& p, const  U& q, const  std::complex<T>& pq,    65                       std::complex<T>& s, std::complex<T>& tau, U& correction)    75  s = std::complex<T> (-rotation.s3, -rotation.s2);    78  tau = conj(s)/(1.0+c);    80  correction = 2.0 * ( c * ( s*conj(pq) ).real() + Sq * ( s*conj(s) ).real() );    87template <unsigned  RC, typename  T>    89                           unsigned i, unsigned  j, unsigned  k, unsigned  l)    95  x[i][j] -= myconj(s)*(h+g*myconj(tau));    97  x[k][l] += s*(g-h*tau);   101template <unsigned  RC, typename  T, typename  U>   102U JacobiRotation ( unsigned  ip, unsigned  iq,    109  calculate_Jacobi (d[ip], d[iq], a[ip][iq], s, tau, correction);   121    rotate_Jacobi(a,s,tau,j,ip,j,iq);   122  for (j=ip+1; j<iq; j++)   123    rotate_Jacobi(a,s,tau,ip,j,j,iq);   124  for (j=iq+1; j<RC; j++)   125    rotate_Jacobi(a,s,tau,ip,j,iq,j);   133    rotate_Jacobi(a,s,tau,j,ip,j,iq);   140    rotate_Jacobi(a,s,tau,ip,j,iq,j);   145  a[iq][ip]=a[ip][iq]=0.0;   151    rotate_Jacobi (v,s,tau,ip,j,iq,j);   158template <typename  T, typename  U, unsigned  RC>   165  for (ip=0; ip<RC; ip++)   166    b[ip] = eval[ip] = myreal( a[ip][ip] );   169  matrix_identity (evec);   171  for (unsigned  iter=0; iter < 50; iter++) {   176    for (ip=0; ip < RC; ip++)   177      for (iq=ip+1; iq < RC; iq++)   178        sum += norm(a[ip][iq]);   186      thresh=0.2*sum/(RC*RC);   188    for (ip=0; ip < RC; ip++)   189      for (iq=ip+1; iq < RC; iq++) {   194        U g = 100.0 * norm(a[ip][iq]);   197             && norm(eval[ip])+g == norm(eval[ip])   198             && norm(eval[iq])+g == norm(eval[iq]) )   200          a[ip][iq]=a[iq][ip]=0.0;   203        else if (norm(a[ip][iq]) > thresh) {   205          U correction = JacobiRotation ( ip, iq, a, evec, eval );   213    for (ip=0; ip < RC; ip++) { Generated using doxygen 1.14.0
 
 |