invort_c |
Table of contents
Procedureinvort_c ( Invert nearly orthogonal matrices ) void invort_c ( ConstSpiceDouble m [3][3], SpiceDouble mit[3][3] ) AbstractConstruct the inverse of a 3x3 matrix with orthogonal columns and non-zero column norms using a numerically stable algorithm. The rows of the output matrix are the columns of the input matrix divided by the length squared of the corresponding columns. Required_ReadingNone. KeywordsMATRIX Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- m I A 3x3 matrix. mit O m after transposition and scaling of rows. Detailed_Inputm is a 3x3 matrix. Detailed_Outputmit is the matrix obtained by transposing m and dividing the rows by squares of their norms. ParametersNone. Exceptions1) If any of the columns of `m' have zero length, the error SPICE(ZEROLENGTHCOLUMN) is signaled by a routine in the call tree of this routine. 2) If any column is too short to allow computation of the reciprocal of its length without causing a floating point overflow, the error SPICE(COLUMNTOOSMALL) is signaled by a routine in the call tree of this routine. FilesNone. ParticularsSuppose that m is the matrix .- -. | A*u B*v C*w | | 1 1 1 | | | | A*u B*v C*w | | 2 2 2 | | | | A*u B*v C*w | | 3 3 3 | `- -' where the vectors (u , u , u ), (v , v , v ), and (w , w , w ) 1 2 3 1 2 3 1 2 3 are unit vectors. This routine produces the matrix: .- -. | a*u a*u a*u | | 1 2 3 | | | | b*v b*v b*v | | 1 2 3 | | | | c*w c*w c*w | | 1 2 3 | `- -' where a = 1/A, b = 1/B, and c = 1/C. 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) Given a double precision 3x3 matrix with mutually orthogonal rows of arbitrary length, compute its inverse. Check that the original matrix times the computed inverse produces the identity matrix. Example code begins here. /. Program invort_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. ./ invort_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 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, 01-NOV-2021 (JDR) Edited the header to comply with NAIF standard. Fixed I/O type of argument "mit" in -Brief_I/O table. Extended -Abstract section. Added complete code example. -CSPICE Version 1.0.0, 02-JAN-2002 (WLT) (NJB) Index_EntriesTranspose a matrix and invert the lengths of the rows Invert a pseudo orthogonal matrix |
Fri Dec 31 18:41:08 2021