src/IntRank2/CartMx2A.cc
/* This function performs a Newton Minimization on an irreducible rank 2 
   Cartesian tensor to obtain a set of Euler angles {alpha, beta, gamma} that
   relate the tensor orientation to its PAS. Prior to the call of this function
   the user should set the Cartesian tensor A (which may be reducible), and
   have obtained the three components {Aiso, delzz, eta} independently.

   The minimizaton begins with an initial guess as to the Euler angles, EAo.
   It then iterates to find the "true" Euler angles, EA, using a minimization
   proceedure involving a Jacobian matrix and Function vector. "True" angles 
   are when the minimization angle corrections have a norm less than the value
   set for NormCut. The number of iterations will not be allowed to exceed
   MaxIter.

   Note that, since the Jacobian matrix and Functional vector are based on
   multi-valued trigonometric functions, false minima can easily occur. The
   resulting Euler angles should ALWAYS be checked by regeneration of the
   Cartesian matrix using spherical PAS components and the determined angle
   and subsequent comparison with the original array that was to be converted.
   The minimization process should be repeated with different starting angles
   if a bad angle set is produced even though the minimization has succeeded
   in getting the correction norm below NormCut. The same can be said when
   the minimization fails because it cannot find a minimium.                 */
This function performs a Newton Minimization on an irreducible rank 2
Cartesian tensor to obtain a set of Euler angles {alpha, beta, gamma} that
relate the tensor orientation to its PAS. Prior to the call of this function
the user should set the Cartesian tensor A (which may be reducible), and
have obtained the three components {Aiso, delzz, eta} independently.

The minimizaton begins with an initial guess as to the Euler angles, EAo.
It then iterates to find the "true" Euler angles, EA, using a minimization
proceedure involving a Jacobian matrix and Function vector. "True" angles
are when the minimization angle corrections have a norm less than the value
set for NormCut. The number of iterations will not be allowed to exceed
MaxIter.

Note that, since the Jacobian matrix and Functional vector are based on
multi-valued trigonometric functions, false minima can easily occur. The
resulting Euler angles should ALWAYS be checked by regeneration of the
Cartesian matrix using spherical PAS components and the determined angle
and subsequent comparison with the original array that was to be converted.
The minimization process should be repeated with different starting angles
if a bad angle set is produced even though the minimization has succeeded
in getting the correction norm below NormCut. The same can be said when
the minimization fails because it cannot find a minimium.
This function performs a Newton Minimization on an irreducible rank 2 Cartesian tensor to obtain a set of Euler angles { alpha beta gamma } that relate the tensor orientation to its PAS . Prior to the call of this function the user should set the Cartesian tensor A ( which may be reducible ) and have obtained the three components { Aiso delzz eta } independently . The minimizaton begins with an initial guess as to the Euler angles EAo . It then iterates to find the " true " Euler angles EA using a minimization proceedure involving a Jacobian matrix and Function vector . " True " angles are when the minimization angle corrections have a norm less than the value set for NormCut . The number of iterations will not be allowed to exceed MaxIter . Note that since the Jacobian matrix and Functional vector are based on multi - valued trigonometric functions false minima can easily occur . The resulting Euler angles should ALWAYS be checked by regeneration of the Cartesian matrix using spherical PAS components and the determined angle and subsequent comparison with the original array that was to be converted . The minimization process should be repeated with different starting angles if a bad angle set is produced even though the minimization has succeeded in getting the correction norm below NormCut . The same can be said when the minimization fails because it cannot find a minimium .
bool CartMx2A::Minimize()
  {
  matrix Jinv;					
  double Ynorm = 0;				
  double a, b, g;				
  EAngles EAY;
  TrackMin(0);					
  EA = EAo;					
  X.put(EAo.alpha(), 0);			
  X.put(EAo.beta(),  1);			
  X.put(EAo.gamma(), 2);
  Y = col_vector(3,complex0);
  for(int k=0; k<MaxIter; k++, Iter++)		
    {
    TrackMin(1);				
    if(!JacobianF()) { JOK=false; return JOK; }	
    JOK = true;					
    Jinv = inv(J);				
    Y    = -1.0*(Jinv*F);			
    TrackMin(-1);				
    Ynorm = Y.norm();				
    if(Ynorm < NormCut) 			
      { TrackMin(2); TrackMin(3); return true; }
    else 					
      {
      X += Y;					
      a=X.getRe(0); b=X.getRe(1); g=X.getRe(2);	
      EA=EAngles(a,b,g);			
      }
    TrackMin(2);				
    }						
  return false;					
  }
bool CartMx2A :: Minimize ( ) { matrix Jinv ; double Ynorm = 0 ; double a , b , g ; EAngles EAY ; TrackMin ( 0 ) ; EA = EAo ; X . put ( EAo . alpha ( ) , 0 ) ; X . put ( EAo . beta ( ) , 1 ) ; X . put ( EAo . gamma ( ) , 2 ) ; Y = col_vector ( 3 , complex0 ) ; for ( int k = 0 ; k < MaxIter ; k ++ , Iter ++ ) { TrackMin ( 1 ) ; if ( ! JacobianF ( ) ) { JOK = false ; return JOK ; } JOK = true ; Jinv = inv ( J ) ; Y = -1.0 * ( Jinv * F ) ; TrackMin ( -1 ) ; Ynorm = Y . norm ( ) ; if ( Ynorm < NormCut ) { TrackMin ( 2 ) ; TrackMin ( 3 ) ; return true ; } else { X += Y ; a = X . getRe ( 0 ) ; b = X . getRe ( 1 ) ; g = X . getRe ( 2 ) ; EA = EAngles ( a , b , g ) ; } TrackMin ( 2 ) ; } return false ; }
This function performs a Newton Minimization on an irreducible rank 2
Cartesian tensor to obtain a set of Euler angles {alpha, beta, gamma} that
relate the tensor orientation to its PAS.
This function performs a Newton Minimization on an irreducible rank 2 Cartesian tensor to obtain a set of Euler angles { alpha beta gamma } that relate the tensor orientation to its PAS .
// Jacobian Inverse // Norm of vector <Y| // Adjusted angles // Track minimization as desired // Initialize Euler angles // Initialize the first pick // for the Euler angles // Iterate with minimization //   Track iteration if wanted //   Get Jacobian & Functional //   Flag Jacobian Is OK //   Generate inverse of J //   Generate update vector |Y> //   Track iteration as desired //   Get norm of correction |Y> //   If no angle corrections //   we are finished iterating //   Update angles next iterate  //     if(Norms.size() >= 20) Norms.pop_front();	//     Keep 20 stored norms max //     Norms.push_back(Ynorm);			//     Store calculate |Y> norm //     if(!CheckNorms())				//     Insure norms decreasing //       { TrackMin(31); return false; } //     Update angles in X //     Individual angle updates //     Set update to EA //   Track iteration if needed //   Go to next iteration // Failed! Can't find angles