xpose_c |
Table of contents
Procedurexpose_c ( Transpose a matrix, 3x3 ) void xpose_c ( ConstSpiceDouble m1 [3][3], SpiceDouble mout [3][3] ) AbstractTranspose a 3x3 matrix. Required_ReadingNone. KeywordsMATRIX Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- m1 I Matrix to be transposed. mout O Transpose of `m1'. Detailed_Inputm1 is any double precision 3x3 matrix. Detailed_Outputmout is a double precision, 3x3 matrix which contains the transpose of `m1'. `mout' may overwrite `m1'. ParametersNone. ExceptionsError free. FilesNone. Particularsxpose_c first copies the diagonal elements of `m1' to `mout'. Then the off-diagonal elements are transposed using a temporary variable in the following order: [0][1] <---> [1][0] [0][2] <---> [2][0] [1][2] <---> [2][1] Since a temporary variable is used, it is possible to transpose a matrix in place. In other words, `mout' may overwrite `m1'. 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 3x3 double precision matrix, find its transpose. Example code begins here. /. Program xpose_ex1 ./ #include <stdio.h> #include "SpiceUsr.h" int main( ) { /. Local variables. ./ SpiceDouble mout [3][3]; SpiceInt i; /. Define the input matrix. ./ SpiceDouble m1 [3][3] = { { 1.0, 2.0, 3.0 }, { 0.0, 4.0, 5.0 }, { 0.0, 6.0, 0.0 } }; /. Compute the transpose of `m1'. ./ xpose_c ( m1, mout ); /. Display the results. ./ printf( "Input matrix (M1):\n" ); printf( "\n" ); for ( i = 0; i < 3; i++ ) { printf( "%5.1f %5.1f %5.1f\n", m1[i][0], m1[i][1], m1[i][2] ); } printf( "\n" ); printf( "Transpose of M1:\n" ); printf( "\n" ); for ( i = 0; i < 3; i++ ) { printf( "%5.1f %5.1f %5.1f\n", mout[i][0], mout[i][1], mout[i][2] ); } return ( 0 ); } When this program was executed on a Mac/Intel/cc/64-bit platform, the output was: Input matrix (M1): 1.0 2.0 3.0 0.0 4.0 5.0 0.0 6.0 0.0 Transpose of M1: 1.0 0.0 0.0 2.0 4.0 6.0 3.0 5.0 0.0 RestrictionsNone. Literature_ReferencesNone. Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) W.M. Owen (JPL) B.V. Semenov (JPL) W.L. Taber (JPL) E.D. Wright (JPL) Version-CSPICE Version 1.2.4, 10-AUG-2021 (BVS) (JDR) Edited the header to comply with NAIF standard. Added complete code example based on existing example. -CSPICE Version 1.2.3, 08-JAN-2014 (BVS) Corrected a minor typo in the header. -CSPICE Version 1.2.2, 16-JAN-2008 (EDW) Corrected typos in header titles: Detailed Input to -Detailed_Input Detailed Output to -Detailed_Output -CSPICE Version 1.2.1, 10-NOV-2006 (EDW) Added -Keywords and -Parameters section headers. Reordered section headers. -CSPICE Version 1.2.0, 22-OCT-1998 (NJB) Made input matrix const. -CSPICE Version 1.1.0, 06-MAR-1998 (EDW) Minor correction to header. -CSPICE Version 1.0.0, 08-FEB-1998 (NJB) (WLT) (WMO) Based on SPICELIB Version 1.0.1, 10-MAR-1992. Index_Entriestranspose a 3x3_matrix |
Fri Dec 31 18:41:15 2021