Index of Functions: A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X 
Index Page
cspice_diags2

Table of contents
Abstract
I/O
Parameters
Examples
Particulars
Exceptions
Files
Restrictions
Required_Reading
Literature_References
Author_and_Institution
Version
Index_Entries


Abstract


   CSPICE_DIAGS2 diagonalizes a symmetric, double precision,
   2x2 matrix.

I/O


   Given:

      symmat   A symmetric 2x2 matrix.

               help, symmat
                  DOUBLE = Array[2,2]

               That is, `symmat' has the form

                  +-        -+
                  |  A    B  |
                  |          |
                  |  B    C  |
                  +-        -+

               This routine uses only the upper-triangular
               elements of `symmat', that is, the elements

                  symmat[0, 0]
                  symmat[0, 1]
                  symmat[1, 1]

               to determine the outputs `diag' and `rotate'.

   the call:

      cspice_diags2, symmat, diag, rotate

   returns:

      diag,
      rotate   are, respectively, a diagonal matrix and a 2x2
               rotation matrix that satisfy the equation

                                   T
                  diag   =   rotate    *  symmat  *  rotate.

               help, diag
                  DOUBLE = Array[2,2]
               help, rotate
                  DOUBLE = Array[2,2]

               In other words, diag is similar to `symmat', and
               rotate is a change-of-basis matrix that
               diagonalizes `symmat'. cspice_diags2 chooses rotate so
               that its angle of rotation has the smallest
               possible magnitude. If there are two rotations
               that meet these criteria (they will be inverses of
               one another), either rotation may be chosen.

Parameters


   None.

Examples


   Any numerical results shown for this example may differ between
   platforms as the results depend on the SPICE kernels used as input
   and the machine specific arithmetic implementation.

   1) Define a symmetric matrix, print the diagonal form of the matrix
      and the corresponding rotation matrix.

      Example code begins here.


      PRO diags2_ex1

         ;;
         ;; Define a symmetric matrix.
         ;;
         mat = [ [1.d, 4.d], [4.d, -5.d]]

         ;;
         ;; Diagonalize mat.
         ;;
         cspice_diags2, mat, diag, rot

         ;;
         ;; Print the diagonal form of mat and
         ;; the corresponding rotation matrix.
         print, 'Diagonal form of mat:'
         print, diag
         print
         print, 'Corresponding rotation matrix:'
         print, rot
         print

         ;;
         ;; Confirm `diag' and `rot'.
         ;;
         diag2 = transpose(rot) ## mat ## rot
         print, 'Difference between cspice_diags2 and IDL native'
         print, 'methods for computing diagonal form of mat:'
         print, diag - diag2

      END


      When this program was executed on a Mac/Intel/IDL8.x/64-bit
      platform, the output was:


      Diagonal form of mat:
             3.0000000       0.0000000
             0.0000000      -7.0000000

      Corresponding rotation matrix:
            0.89442719     -0.44721360
            0.44721360      0.89442719

      Difference between cspice_diags2 and IDL native
      methods for computing diagonal form of mat:
         4.4408921e-16   2.2204460e-16
             0.0000000       0.0000000


      Note that the difference between cspice_diags2 and IDL native
      methods should be the zero matrix to double precision round-off
      error.

Particulars


   The capability of diagonalizing a 2x2 symmetric matrix is
   especially useful in a number of geometric applications
   involving quadratic curves such as ellipses. Such curves are
   described by expressions of the form

         2                    2
      a x   +   b xy   +   C y   +   D x    +    E y   +   F   =   0.

   Diagonalization of the matrix

      .-         -.
      | a     b/2 |
      |           |
      | b/2    C  |
      `-         -'

   allows us to perform a coordinate transformation (a rotation,
   specifically) such that the equation of the curve becomes

         2         2
      P u   +   q v   +   r u    +    s v   +   T   =   0

   in the transformed coordinates. This form is much easier to
   handle. If the quadratic curve in question is an ellipse,
   we can easily find its center, semi-major axis, and semi-minor
   axis from the second equation.

   Ellipses turn up frequently in navigation geometry problems;
   for example, the limb and terminator (if we treat the Sun as a
   point source) of a body modeled as a tri-axial ellipsoid are
   ellipses.

   A mathematical note: because `symmat' is symmetric, we can ALWAYS
   find an orthogonal similarity transformation that diagonalizes
   `symmat', and we can choose the similarity transformation to be a
   rotation matrix. By `orthogonal' we mean that if the `rotate' is
   the matrix in question, then

            T                         T
      rotate  rotate  =  rotate rotate  =  I.

   The reasons this routine handles only the 2x2 case are: first,
   the 2x2 case is much simpler than the general case, in which
   iterative diagonalization methods must be used, and second, the
   2x2 case is adequate for solving problems involving ellipses in
   3 dimensional space. Finally, this routine can be used to
   support a routine that solves the general-dimension
   diagonalization problem for symmetric matrices.

   Another feature of the routine that might provoke curiosity is
   its insistence on choosing the diagonalization matrix that
   rotates the original basis vectors by the smallest amount. The
   rotation angle of `rotate' is of no concern for most applications,
   but can be important if this routine is used as part of an
   iterative diagonalization method for higher-dimensional matrices.
   In that case, it is most undesirable to interchange diagonal
   matrix elements willy-nilly; the matrix to be diagonalized could
   get ever closer to being diagonal without converging. Choosing
   the smallest rotation angle precludes this possibility.

Exceptions


   1)  The matrix element symmat[1,0] is not used in this routine's
       computations, so the condition

          symmat[0,1]  ne  symmat[1,0]

       has no effect on this routine's outputs.

   2)  If the input argument `symmat' is undefined, an error is
       signaled by the IDL error handling system.

   3)  If the input argument `symmat' is not of the expected type, or
       it does not have the expected dimensions and size, an error is
       signaled by the Icy interface.

   4)  If any of the output arguments, `diag' or `rotate', is not a
       named variable, an error is signaled by the Icy interface.

Files


   None.

Restrictions


   None.

Required_Reading


   ICY.REQ

Literature_References


   [1]  T. Apostol, "Calculus, Vol. II," chapter 5, "Eigenvalues of
        Operators Acting on Euclidean Spaces," John Wiley & Sons,
        1969.

Author_and_Institution


   J. Diaz del Rio     (ODC Space)
   E.D. Wright         (JPL)

Version


   -Icy Version 1.0.1, 17-JUN-2021 (JDR)

       Added -Parameters, -Exceptions, -Files, -Restrictions,
       -Literature_References and -Author_and_Institution sections.

       Edited the header to comply with NAIF standard. Updated code
       example and extended -Particulars section.

       Removed reference to the routine's corresponding CSPICE header from
       -Abstract section.

       Added arguments' type and size information in the -I/O section.

   -Icy Version 1.0.0, 16-JUN-2003 (EDW)

Index_Entries


   diagonalize symmetric 2x2_matrix



Fri Dec 31 18:43:03 2021