Table of contents
CSPICE_MXV calculates the product of a 3x3 double precision
matrix and a 3-vector (a classic 3x1 matrix) using the
classic definition of the matrix multiplication. An error
signals for any input non 3x3 matrix and any non 3-vector.
Given:
m an arbitrary 3x3 double precision matrix.
help, m
DOUBLE = Array[3,3]
vin an arbitrary 3-dimensional double precision vector.
help, vin
DOUBLE = Array[3]
the call:
cspice_mxv, m, vin, vout
returns:
vout a 3-dimensional double precision vector.
help, vout
DOUBLE = Array[3]
`vout' is the product vout = m * vin. `vout' may overwrite
`vin'.
`vout' has the form of an IDL row vector, i.e.:
vout = [ vout1, vout2, vout3 ]
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 a 3x3 matrix and a 3-vector, multiply the matrix by
the vector.
Example code begins here.
PRO mxv_ex1
;;
;; Define `m' and `vin'.
;;
m = [[0.0, 1.0, 0.0], [-1.0, 0.0, 0.0], [0.0, 0.0, 1.0]]
vin = [ 1.0, 2.0, 3.0 ]
;;
;; Multiply `m' by `vin'.
;;
cspice_mxv, m, vin, vout
print, format='(A)', 'M1 times VIN:'
print, format='(3F10.3)', vout
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
M1 times VIN:
2.000 -1.000 3.000
The code reflects precisely the following mathematical expression
For each value of the subscript `i' from 0 to 2:
2
.-----
\
vout[i] = ) m[k,i] * vin[k]
/
'-----
k=0
The intermediate results of the operation performed by this routine
are buffered in a temporary vector which is later moved to the output
vector. Thus `vout' can be actually be `vin' if desired without
interfering with the computation.
Native IDL code to calculate the same result:
vout = m ## vin
returns a column 3 vector, an IDL 1x3 matrix.
Another operation:
vout = transpose(m) # vin
returns an IDL row 3 vector.
1) If any of the input arguments, `m' or `vin', is undefined, an
error is signaled by the IDL error handling system.
2) If any of the input arguments, `m' or `vin', 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 `vout' 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 `m' and `vin' so that a floating point overflow does
not occur.
ICY.REQ
None.
J. Diaz del Rio (ODC Space)
E.D. Wright (JPL)
-Icy Version 1.1.0, 25-AUG-2021 (JDR)
Changed the input argument name "mat", "vec", and "vecout" to
"m", "vin", and "vout" for compliancy with other routines.
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.1, 09-DEC-2005 (EDW)
Added -Examples section.
-Icy Version 1.0.0, 16-JUN-2003 (EDW)
matrix times 3-dimensional vector
|