mxvg |
Table of contents
ProcedureMXVG ( Matrix time vector, general dimension ) SUBROUTINE MXVG ( M1, V2, NR1, NC1R2, VOUT ) AbstractMultiply a matrix and a vector of arbitrary size. Required_ReadingNone. KeywordsMATRIX VECTOR DeclarationsIMPLICIT NONE INTEGER NR1 INTEGER NC1R2 DOUBLE PRECISION M1 ( NR1,NC1R2 ) DOUBLE PRECISION V2 ( NC1R2 ) DOUBLE PRECISION VOUT ( NR1 ) Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- M1 I Left-hand matrix to be multiplied. V2 I Right-hand vector to be multiplied. NR1 I Row dimension of M1 and length of VOUT. NC1R2 I Column dimension of M1 and length of V2. VOUT O Product vector M1*V2. Detailed_InputM1 is a double precision matrix of arbitrary size which forms the left-hand matrix of the multiplication. V2 is a double precision vector on the right of the multiplication. NR1 is the row dimension of M1 and length of VOUT. NC1R2 is the column dimension of M1 and length of V2. Detailed_OutputVOUT is the double precision vector which results from the expression VOUT = (M1) x V2. ParametersNone. ExceptionsError free. FilesNone. ParticularsThe code reflects precisely the following mathematical expression For each value of the subscript I from 1 to NR1, VOUT(I) = Summation from K=1 to NC1R2 of ( M1(I,K) * V2(K) ) 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 2x3 matrix and a 3-vector, multiply the matrix by the vector. Example code begins here. PROGRAM MXVG_EX1 IMPLICIT NONE C C Local variables. C DOUBLE PRECISION M ( 2, 3 ) DOUBLE PRECISION VIN ( 3 ) DOUBLE PRECISION VOUT ( 2 ) INTEGER I INTEGER J C C Define M and VIN. C DATA M / 1.0D0, 2.0D0, . 1.0D0, 3.0D0, . 1.0D0, 4.0D0 / DATA VIN / 1.0D0, 2.0D0, 3.0D0 / C C Multiply M by VIN. C CALL MXVG ( M, VIN, 2, 3, VOUT ) WRITE(*,'(A)') 'M times VIN:' WRITE(*,'(2F10.3)') VOUT END When this program was executed on a Mac/Intel/gfortran/64-bit platform, the output was: M times VIN: 6.000 20.000 Restrictions1) The user is responsible for checking the magnitudes of the elements of M1 and V2 so that a floating point overflow does not occur. Literature_ReferencesNone. Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) W.M. Owen (JPL) W.L. Taber (JPL) VersionSPICELIB Version 1.1.0, 04-JUL-2021 (JDR) Added IMPLICIT NONE statement. Edited the header to comply with NAIF standard. Added complete code example based on the existing example. SPICELIB Version 1.0.2, 23-APR-2010 (NJB) Re-ordered header sections and made minor formatting changes. SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) Comment section for permuted index source lines was added following the header. SPICELIB Version 1.0.0, 31-JAN-1990 (WMO) |
Fri Dec 31 18:36:35 2021