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 invert_c
Table of contents
Procedure Abstract Required_Reading Keywords Brief_I/O Detailed_Input | Detailed_Output Parameters Exceptions Files Particulars Examples | Restrictions Literature_References Author_and_Institution Version Index_Entries
#### Procedure
       invert_c ( Invert a 3x3 matrix )

       void invert_c ( ConstSpiceDouble  m   [3][3],
                       SpiceDouble       mout[3][3] )
#### Abstract
       Generate the inverse of a 3x3 matrix.
#### Required_Reading
       None.
#### Keywords
       MATH
       MATRIX
#### Brief_I/O
       VARIABLE  I/O  DESCRIPTION
       --------  ---  --------------------------------------------------
       m          I   Matrix to be inverted.
       mout       O   Inverted matrix (m)^-1.
#### Detailed_Input
       m           is an arbitrary 3x3 matrix. The limits on the size of
                   elements of `m' are determined by the process of calculating
                   the cofactors of each element of the matrix. For a 3x3
                   matrix this amounts to the differencing of two terms, each
                   of which consists of the multiplication of two matrix
                   elements. This multiplication must not exceed the range
                   of double precision numbers or else an overflow error will
                   occur.
#### Detailed_Output
       mout        is the inverse of `m' and is calculated explicitly using
                   the matrix of cofactors. `mout' is set to be the zero matrix
                   if `m' is singular.

                   `mout' can overwrite `m'.
#### Parameters
       None.
#### Exceptions
       1)  No internal checking on the input matrix `m' is performed except
           on the size of its determinant. Thus it is possible to generate a
           floating point overflow or underflow in the process of
           calculating the matrix of cofactors.

       2)  If the determinant is less than 10**-16, the matrix is deemed to
           be singular and the output matrix is filled with zeros.
#### Files
       None.
#### Particulars
       A temporary matrix is used to compute the result, so the output
       matrix may overwrite the input matrix.
#### Examples
       The numerical results shown for this example may differ across
       platforms. The results depend on the SPICE kernels used as
       input, the compiler and supporting libraries, and the machine
       specific arithmetic implementation.

       1) Given a double precision 3x3 matrix, compute its inverse. Check
          that the original matrix times the computed inverse produces
          the identity matrix.

          Example code begins here.

          /.
             Program invert_ex1
          ./
          #include <stdio.h>
          #include "SpiceUsr.h"

          int main( )
          {

             /.
             Local variables.
             ./
             SpiceDouble          imat   [3][3];
             SpiceDouble          mout   [3][3];

             SpiceInt             i;

             /.
             Define a matrix to invert.
             ./
             SpiceDouble          m      [3][3] = { {0.0, -1.0, 0.0},
                                                    {0.5,  0.0, 0.0},
                                                    {0.0,  0.0, 1.0} };

             printf( "Original Matrix:\n" );
             for ( i = 0; i < 3; i++ )
             {

                printf( "%16.7f %15.7f %15.7f\n", m[i][0], m[i][1], m[i][2] );

             }

             /.
             Invert the matrix, then output.
             ./
             invert_c ( m, mout );

             printf( " \n" );
             printf( "Inverse Matrix:\n" );
             for ( i = 0; i < 3; i++ )
             {

                printf( "%16.7f %15.7f %15.7f\n",
                        mout[i][0], mout[i][1], mout[i][2] );

             }

             /.
             Check the `m' times `mout' produces the identity matrix.
             ./
             mxm_c ( m, mout, imat );

             printf( " \n" );
             printf( "Original times inverse:\n" );
             for ( i = 0; i < 3; i++ )
             {

                printf( "%16.7f %15.7f %15.7f\n",
                        imat[i][0], imat[i][1], imat[i][2] );

             }

             return ( 0 );
          }

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

          Original Matrix:
                 0.0000000      -1.0000000       0.0000000
                 0.5000000       0.0000000       0.0000000
                 0.0000000       0.0000000       1.0000000

          Inverse Matrix:
                 0.0000000       2.0000000      -0.0000000
                -1.0000000       0.0000000      -0.0000000
                 0.0000000      -0.0000000       1.0000000

          Original times inverse:
                 1.0000000       0.0000000       0.0000000
                 0.0000000       1.0000000       0.0000000
                 0.0000000       0.0000000       1.0000000
#### Restrictions
       1)  The input matrix must be such that generating the cofactors will
           not cause a floating point overflow or underflow. The
           strictness of this condition depends, of course, on the computer
           installation and the resultant maximum and minimum values of
           double precision numbers.
#### Literature_References
       None.
#### Author_and_Institution
       N.J. Bachman        (JPL)
       J. Diaz del Rio     (ODC Space)
       W.M. Owen           (JPL)
#### Version
       -CSPICE Version 1.1.0, 06-JUL-2021 (JDR)

           Changed input argument name "m1" to "m" for consistency with
           other routines.

           Updated the header to comply with NAIF standard. Added
           complete code example.

       -CSPICE Version 1.0.0, 13-SEP-1999 (NJB) (WMO)
#### Index_Entries
       invert a 3x3_matrix
#### Link to routine invert_c source file invert_c.c

    Fri Dec 31 18:41:08 2021