Table of contents
CSPICE_MTXM calculates the product of an input 3x3 matrices'
transpose with a second 3x3 matrix using the classic definition
of matrix multiplication, returning a 3x3 matrix as output.
Given:
m1,
m2 two arbitrary double precision 3x3 matrices.
help, m1
DOUBLE = Array[3,3]
help, m2
DOUBLE = Array[3,3]
the call:
cspice_mtxm, m1, m2, mout
returns:
mout a double precision 3x3 matrix, the result of the matrix
multiplication of the transpose of matrix `m1' by `m2'.
help, mout
DOUBLE = Array[3,3]
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 matrices, multiply the transpose of the first
matrix by the second one.
Example code begins here.
PRO mtxm_ex1
;;
;; Define `m1' and `m2'.
;;
m1 = [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]
m2 = [[1.0, 1.0, 0.0], [-1.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
;;
;; Multiply the transpose of `m1' by `m2'.
;;
cspice_mtxm, m1, m2, mout
print, format='(A)', 'Transpose of M1 times M2:'
for i=0, 2 do begin
print, format='(3F10.3)', mout[0,i], mout[1,i], mout[2,i]
endfor
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
Transpose of M1 times M2:
-3.000 5.000 7.000
-3.000 7.000 8.000
-3.000 9.000 9.000
Note that the native IDL code to calculate the same matrix
result is:
mout = transpose(m1) ## m2
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[k][i] * m2[k][j]
k=0
Note that the reversal of the `k' and `i' subscripts in the left-hand
matrix `m1' is what makes `mout' the product of the TRANSPOSE of `m1'
and not simply of `m1' itself. Also, the intermediate results of
the operation above are buffered in a temporary matrix which is
later moved to the output matrix. Thus `mout' can be actually be
`m1' or `m2' if desired without interfering with the computations.
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)
Changed the argument names "a", "b" and "c" to "m1", "m2" and "mout"
in the header to match those in the code.
Edited the header to comply with NAIF standard. Added complete code
example.
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_transpose times matrix 3x3_case
|