Table of contents
CSPICE_MXMT calculates the product of an input 3x3 matrix
with a second 3x3 matrices' transpose using the classic
definition of matrix multiplication, returning a 3x3 matrix
as output.
Given:
m1 an arbitrary 3x3 double precision matrix.
help, m1
DOUBLE = Array[3,3]
m2 an arbitrary 3x3 double precision matrix.
help, m2
DOUBLE = Array[3,3]
Typically, `m2' will be a rotation matrix since then its
transpose is its inverse (but this is NOT a requirement).
the call:
cspice_mxmt, m1, m2, mout
returns:
mout a 3x3 double precision matrix.
help, mout
DOUBLE = Array[3,3]
`mout' is the product
T
mout = m1 x m2
None.
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) Given two 3x3 double precision matrices, multiply the first
matrix by the transpose of the second one.
Example code begins here.
PRO mxmt_ex1
;;
;; Define `m1'.
;;
m1 = [ [ 0.D0, 1.D0, 0.D0 ], $
[ -1.D0, 0.D0, 0.D0 ], $
[ 0.D0, 0.D0, 1.D0 ] ]
;;
;; Make `m2' equal to `m1'.
;;
cspice_mequ, m1, m2
;;
;; Multiply `m1' by the transpose of `m2'.
;;
cspice_mxmt, m1, m2, mout
print, format='(A)', 'M1:'
print, format='(3F16.7)', m1
print
print, format='(A)', 'M2:'
print, format='(3F16.7)', m2
print
print, format='(A)', 'M1 times transpose of M2:'
print, format='(3F16.7)', mout
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
M1:
0.0000000 1.0000000 0.0000000
-1.0000000 0.0000000 0.0000000
0.0000000 0.0000000 1.0000000
M2:
0.0000000 1.0000000 0.0000000
-1.0000000 0.0000000 0.0000000
0.0000000 0.0000000 1.0000000
M1 times transpose of M2:
1.0000000 0.0000000 0.0000000
0.0000000 1.0000000 0.0000000
0.0000000 0.0000000 1.0000000
The code reflects precisely the following mathematical expression
For each value of the subscripts `i' and `j' from 0 to 2:
2
.-----
\
mout[i,j] = ) m1[i,k] * m2[j,k]
/
'-----
k=0
Note that the reversal of the `k' and `j' subscripts in the right-
hand matrix `m2' is what makes `mout' the product of the TRANSPOSE of
`m2' and not simply of `m2' itself.
Native IDL code to calculate the same matrix result:
c = a ## transpose(b)
1) If any of the input arguments, `m1' or `m2', is undefined, an
error is signaled by the IDL error handling system.
2) If any of the input arguments, `m1' or `m2', is not of the
expected type, or it does not have the expected dimensions and
size, an error is signaled by the Icy interface.
3) If the output argument `mout' is not a named variable, an
error is signaled by the Icy interface.
None.
1) The user is responsible for checking the magnitudes of the
elements of `m1' and `m2' so that a floating point overflow does
not occur. (In the typical use where `m1' and `m2' are rotation
matrices, this not a risk at all.)
ICY.REQ
None.
J. Diaz del Rio (ODC Space)
E.D. Wright (JPL)
-Icy Version 1.0.3, 10-AUG-2021 (JDR)
Edited the header to comply with NAIF standard. Added complete
code examples based on existing code fragments.
Changed the argument names in order to match those given within the
IDL bridge code.
Added -Parameters, -Exceptions, -Files, -Restrictions,
-Literature_References and -Author_and_Institution sections, and
completed -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.2, 13-JUN-2011 (EDW)
Edits to comply with NAIF standard for Icy headers.
-Icy Version 1.0.1, 09-DEC-2005 (EDW)
Added -Examples section.
-Icy Version 1.0.0, 16-JUN-2003 (EDW)
matrix times matrix_transpose 3x3_case
|