ident_c |
Table of contents
Procedureident_c ( Return the 3x3 identity matrix ) void ident_c ( SpiceDouble matrix[3][3] ) AbstractReturn the 3x3 identity matrix. Required_ReadingNone. KeywordsMATRIX Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- matrix O The 3x3 identity matrix. Detailed_InputNone. Detailed_Outputmatrix is the 3x3 Identity matrix. That `matrix' is the following .- -. | 1.0 0.0 0.0 | | 0.0 1.0 0.0 | | 0.0 0.0 1.0 | `- -' ParametersNone. ExceptionsError free. FilesNone. ParticularsThis is a utility routine for obtaining the 3x3 identity matrix so that you may avoid having to write the loop or assignments needed to get the matrix. ExamplesThe 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) Define a 3x3 matrix and compute its inverse using the CSPICE routine invert_c. Verify the accuracy of the computed inverse using the mathematical identity -1 m x m - i = 0 where `i' is the 3x3 identity matrix. Example code begins here. /. Program ident_ex1 ./ #include <stdio.h> #include "SpiceUsr.h" int main( ) { /. Local variables. ./ SpiceDouble idmat [3][3]; SpiceDouble imat [3][3]; SpiceDouble mout [3][3]; SpiceDouble mzero [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. ./ ident_c ( idmat ); mxm_c ( m, mout, imat ); vsubg_c ( (SpiceDouble *)imat, (SpiceDouble *)idmat, 9, (SpiceDouble *)mzero ); printf( "\n" ); printf( "Original times inverse minus identity:\n" ); for ( i = 0; i < 3; i++ ) { printf( "%16.7f %15.7f %15.7f\n", mzero[i][0], mzero[i][1], mzero[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 minus identity: 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 RestrictionsNone. Literature_ReferencesNone. Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) W.L. Taber (JPL) Version-CSPICE Version 1.0.1, 02-JUN-2021 (JDR) Edited the header to comply with NAIF standard. Added complete code example. -CSPICE Version 1.0.0, 01-JUN-1999 (NJB) (WLT) Index_EntriesGet the 3x3 identity matrix |
Fri Dec 31 18:41:08 2021