src/IntRank2/CartMx2A.cc
/* This function will generate a 3x3 Jacobian matrix and a 3x1 Functional
   vector for use in a Newton minimization to determine the three Euler angles
   EA:{alpha, beta, gamma} associated with an irreducible rank 2 Cartesian
   spatial tensor A. The angles relate the tensor PAS to the orientation in 
   which it exists. The Jacobian array J & Funcitonal vector F produced are


          [  @f1      @f1     @f1   ]                 [                      ]
          | ------   -----   ------ |                 | f1(alpha,beta,gamma) |
          | @alpha   @beta   @gamma |                 |                      |
          |                         |                 |                      |
          |  @f2      @f2     @f2   |                 |                      |
  J(EA) = | ------   -----   ------ |       |F(EA)> = | f2(alpha,beta,gamma) | 
          | @alpha   @beta   @gamma |                 |                      |
          |                         |                 |                      |
          |  @f3      @f3     @f3   |                 |                      |
          | ------   -----   ------ |                 | f3(alpha,beta,gamma) |
          [ @alpha   @beta   @gamma ]                 [                      ]


   The function takes the EAngles EA containing a possible set of Euler angles.
   Were these the true angles of the problem the functional vector will be zero
   by design, i.e. |F> = 0. In addition, the function uses the vector |Av>
   which contains 6 of the original components of the Cartesian matrix, A, being
   treated 
                       T
                   |Av>  = [ Axx, Axy, Axz, Ayy, Ayz, Azz ]
  
   Also used are the values of delzz (PASDelzz) and eta (EtaVal), both of 
   which may be determined directly from the Cartesian array A. The function
   takes an optional print flag allows the user to view the process involved
   in generating J and |F>.

   There are 6 possible functions that may be used for generating the rows of
   J and |F>, one for each input Cartesian element of A (Auv in vector |Av>). 
   Hard-coded in are the formula for generating the elements of the Jacobian
   and functional vector for all six. However, the minimization to obtain
   the Euler angles demands we use only three of these. Hence, the routine 
   will select out three of the six that are deemed good functions.... namely
   ones that will not produce a singular Jacobian matrix. In this problem a
   singular Jacobian matrix could easily occur since the six functions are
   inter-related and may produce identical rows in J or may produce a zero
   row in J because on often finds zero angles in the set EA.

   For more information on the Jacobian matrix, Functional vector F, and 
   overall minimization scheme see the GAMMA documentation on class IntRank2A.


	   Input	*	Av	: Vector - { Axx,Axy,Axz,Ayy,Ayz,Azz }
			*	PASDelzz: PAS delzz value
	  		*	EtaVal  : Asymmetry value
	   		*	EA	: Euler Angles {alpha,beta,gamma} rad
	  		*	F       : Functional Vector - {f1,f2,f3}
	  		*	J	: Jacobian Matrix (3x3)
	  			pl      : Print level for output
	   Output		TF      : Given the values in EA & |Av> the
	  				  vector |F> and Jacobian matrix J
	  				  are generated.  The function will
	  				  return true if this procedure is
	  				  deemed OK, false if it appears that
	  				  one cannot build a proper Jacobian
	   Note				: * Input variables are class internal
	   Note				: USED FOR FITTING {alpha,beta,gamma}
	  				  WHEN WE KNOW {delzz,eta}
	   Note				: The values in Av must come from a
					  symmetric traceless matrix
	   Note				: If the function returns false, one
	  				  should try a different set of 
                                          Euler Angles.                      */
This function will generate a 3x3 Jacobian matrix and a 3x1 Functional
vector for use in a Newton minimization to determine the three Euler angles
EA:{alpha, beta, gamma} associated with an irreducible rank 2 Cartesian
spatial tensor A. The angles relate the tensor PAS to the orientation in
which it exists. The Jacobian array J & Funcitonal vector F produced are



The function takes the EAngles EA containing a possible set of Euler angles.
Were these the true angles of the problem the functional vector will be zero
by design, i.e. |F> = 0. In addition, the function uses the vector |Av>
which contains 6 of the original components of the Cartesian matrix, A, being
treated
T
|Av>  = [ Axx, Axy, Axz, Ayy, Ayz, Azz ]

Also used are the values of delzz (PASDelzz) and eta (EtaVal), both of
which may be determined directly from the Cartesian array A. The function
takes an optional print flag allows the user to view the process involved
in generating J and |F>.

There are 6 possible functions that may be used for generating the rows of
J and |F>, one for each input Cartesian element of A (Auv in vector |Av>).
Hard-coded in are the formula for generating the elements of the Jacobian
and functional vector for all six. However, the minimization to obtain
the Euler angles demands we use only three of these. Hence, the routine
will select out three of the six that are deemed good functions.... namely
ones that will not produce a singular Jacobian matrix. In this problem a
singular Jacobian matrix could easily occur since the six functions are
inter-related and may produce identical rows in J or may produce a zero
row in J because on often finds zero angles in the set EA.

For more information on the Jacobian matrix, Functional vector F, and
overall minimization scheme see the GAMMA documentation on class IntRank2A.


This function will generate a 3x3 Jacobian matrix and a 3x1 Functional vector for use in a Newton minimization to determine the three Euler angles EA : { alpha beta gamma } associated with an irreducible rank 2 Cartesian spatial tensor A . The angles relate the tensor PAS to the orientation in which it exists . The Jacobian array J & Funcitonal vector F produced are The function takes the EAngles EA containing a possible set of Euler angles . Were these the true angles of the problem the functional vector will be zero by design i . e . |F > = 0 . In addition the function uses the vector |Av > which contains 6 of the original components of the Cartesian matrix A being treated T |Av > = [ Axx Axy Axz Ayy Ayz Azz ] Also used are the values of delzz ( PASDelzz ) and eta ( EtaVal ) both of which may be determined directly from the Cartesian array A . The function takes an optional print flag allows the user to view the process involved in generating J and |F > . There are 6 possible functions that may be used for generating the rows of J and |F > one for each input Cartesian element of A ( Auv in vector |Av > ) . Hard - coded in are the formula for generating the elements of the Jacobian and functional vector for all six . However the minimization to obtain the Euler angles demands we use only three of these . Hence the routine will select out three of the six that are deemed good functions .... namely ones that will not produce a singular Jacobian matrix . In this problem a singular Jacobian matrix could easily occur since the six functions are inter - related and may produce identical rows in J or may produce a zero row in J because on often finds zero angles in the set EA . For more information on the Jacobian matrix Functional vector F and overall minimization scheme see the GAMMA documentation on class IntRank2A .
void CartMx2A::Axx(double& f, double& dfda, double& dfdb, double& dfdg) const
  {
  double term1, term2, term3;
  term1 = C2a*(3.0*Ssqb + EtaVal*Csqbp1*C2g);	
  term2 = -2.0*EtaVal*S2a*Cb*S2g;		
  term3 = -3.0*Csqb + 1.0 - EtaVal*Ssqb*C2g;	
  f = term1+term2+term3;			
  term1 = -2.0*S2a*(3.0*Ssqb+EtaVal*Csqbp1*C2g);
  term2 = -4.0*EtaVal*C2a*Cb*S2g;		
  dfda =  term1 + term2;			
  term1 =  C2a*(6.0*SbCb - 2.*EtaVal*SbCb*C2g);	
  term2 =  2.0*EtaVal*S2a*Sb*S2g;		
  term3 =  6.0*SbCb - 2.0*EtaVal*SbCb*C2g;	
  dfdb =  term1 + term2 + term3;		
  term1 = -2.0*EtaVal*C2a*Csqbp1*S2g;		
  term2 = -4.0*EtaVal*S2a*Cb*C2g;		
  term3 =  2.0*EtaVal*Ssqb*S2g;			
  dfdg = term1 + term2;				
  }
void CartMx2A :: Axx ( double & f , double & dfda , double & dfdb , double & dfdg ) const { double term1 , term2 , term3 ; term1 = C2a * ( 3.0 * Ssqb + EtaVal * Csqbp1 * C2g ) ; term2 = -2.0 * EtaVal * S2a * Cb * S2g ; term3 = -3.0 * Csqb + 1.0 - EtaVal * Ssqb * C2g ; f = term1 + term2 + term3 ; term1 = -2.0 * S2a * ( 3.0 * Ssqb + EtaVal * Csqbp1 * C2g ) ; term2 = -4.0 * EtaVal * C2a * Cb * S2g ; dfda = term1 + term2 ; term1 = C2a * ( 6.0 * SbCb - 2. * EtaVal * SbCb * C2g ) ; term2 = 2.0 * EtaVal * S2a * Sb * S2g ; term3 = 6.0 * SbCb - 2.0 * EtaVal * SbCb * C2g ; dfdb = term1 + term2 + term3 ; term1 = -2.0 * EtaVal * C2a * Csqbp1 * S2g ; term2 = -4.0 * EtaVal * S2a * Cb * C2g ; term3 = 2.0 * EtaVal * Ssqb * S2g ; dfdg = term1 + term2 ; }
This function will generate a 3x3 Jacobian matrix and a 3x1 Functional
vector for use in a Newton minimization to determine the three Euler angles
EA:{alpha, beta, gamma} associated with an irreducible rank 2 Cartesian
spatial tensor A.
This function will generate a 3x3 Jacobian matrix and a 3x1 Functional vector for use in a Newton minimization to determine the three Euler angles EA : { alpha beta gamma } associated with an irreducible rank 2 Cartesian spatial tensor A .
//                    Generate Function Value f Based On Axx   // cos(2a)*{3*sin(b)*sin(b) + // eta*[cos(b)*cos(b)+1]cos(2g)} // -2*eta*sin(2a)*cos(b)*sin*2g) // -3*cos(b)*cos(b)+1 +  //    eta*sin(b)*sin(b)*cos(2g)  // This is unscaled fxx //                 Generate Jacobian Value df/da Based On Axx   // -2*sin(2a)*{3*sin(b)*sin(b)+ // eta*[1+cos(b)*cos(b)]cos(2g)} // -4*eta*sin(2a)*cos(b)*sin(2g) // This is unscaled @fxx/@alpha //                 Generate Jacobian Value df/db Based On Axx   // sin(2a)*{6*sin(b)*cos(b) - // 2*eta*sin(b)*cos(b)*cos(2g)} // 2*eta*cos(2a)*sin(b)*sin(2g) // 6*cos(b)*sin(b) -  //  2*eta*sin(b)*cos(b)*cos(2g) // This is unscaled @fxx/@beta //                 Generate Jacobian Value df/dg Based On Axx   // -2.0*eta*sin(2a)* //    [cos(b)*cos(b)+1]*sin(2g) //  4*eta*cos(2a)*cos(b)*cos //  2*eta*sin(b)*sin(b)*sin(2g) // This is unscaled @fxx/@gamma