F004: Matrix Multiplication

Author(s): H. Lipps Library: KERNLIB
Submitter: Submitted: 18.12.1979
Language: Fortran or Assembler or COMPASS Revised: 27.05.1987

These subprograms calculate the matrix product

displaymath227

where tex2html_wrap_inline229 denotes the conjugate of the complex matrix Y, or one of the matrix expressions

displaymath231

Structure:

SUBROUTINE subprograms
User Entry Names:
RMMLA, RMMLS, RMMLT, RMNMA, RMNMS,
DMMLA, DMMLS, DMMLT, DMNMA, DMNMS,
CMMLA, CMMLS, CMMLT, CMNMA, CMNMS, CMMLTC

External References: LOCF (some Fortran versions only).

Usage:

For tex2html_wrap_inline233 (type REAL), tex2html_wrap_inline235 (type DOUBLE PRECISION), tex2html_wrap_inline237 (type COMPLEX):

CALL tMMLT (M,N,K,X11,X12,X21,Y11,Y12,Y21,Z11,Z12,Z21,W) tex2html_wrap_inline239
CALL tMMLA (M,N,K,X11,X12,X21,Y11,Y12,Y21,Z11,Z12,Z21) tex2html_wrap_inline241
CALL tMMLS (M,N,K,X11,X12,X21,Y11,Y12,Y21,Z11,Z12,Z21) tex2html_wrap_inline243
CALL tMNMA (M,N,K,X11,X12,X21,Y11,Y12,Y21,Z11,Z12,Z21) tex2html_wrap_inline245
CALL tMNMS (M,N,K,X11,X12,X21,Y11,Y12,Y21,Z11,Z12,Z21) tex2html_wrap_inline247
CALL CMMLTC(M,N,K,X11,X12,X21,Y11,Y12,Y21,Z11,Z12,Z21,W) tex2html_wrap_inline249

M,N,K
(INTEGER) The mathematical dimensions of the matrices: X has M rows and N columns, Y has N rows and K columns, Z has M rows and K columns.
X11,X12,X21
(Type according to t) Array elements. They must contain the elements tex2html_wrap_inline251 of the matrix X.
Y11,Y12,Y21
(Type according to t) Array elements. They must contain the elements tex2html_wrap_inline253 of the matrix Y.
Z11,Z12,Z21
(Type according to t) Array elements. On exit, they will contain the elements tex2html_wrap_inline255 of the matrix Z.
W
(Type according to t) Working space array as specified below, required only if Z overlaps X or Y. Otherwise a dummy variable.
For tex2html_wrap_inline257 or tex2html_wrap_inline259 or tex2html_wrap_inline261 , all subroutines return control without action.

The matrices X, Y and Z need not to be stored according to the Fortran conventions: any equidistant spacing of their rows and columns is permitted. In particular, matrices may be stored row-wise. Each subroutine can work with the transpose of a matrix. To make this possible, each matrix is specified in the calling sequence by three arguments. For example, the called subroutine will operate on the matrix tex2html_wrap_inline263 if the actual arguments which replace X11, X12, X21 in the calling sequence are tex2html_wrap_inline265 , and will operate on the transpose tex2html_wrap_inline267 of A if the actual arguments are tex2html_wrap_inline269 .

The only cases in which the result matrix Z is permitted to overlap X or Y are the following:

tMMLT: tex2html_wrap_inline271 or tex2html_wrap_inline273 , provided W is an array of at least K elements.
tex2html_wrap_inline275 or tex2html_wrap_inline277 , provided W is an array of at least M elements.
CMMLTC: tex2html_wrap_inline279 or tex2html_wrap_inline281 , provided W is an array of at least K elements.
tex2html_wrap_inline283 or tex2html_wrap_inline285 , provided W is an array of at least M elements.

Accuracy:

On computers with IBM 370 architecture, all routines that accumulate the inner product of type REAL or COMPLEX use double-precision arithmetic internally; the final result is then rounded to single precision.

Notes:

The product of a matrix and its transpose (or Hermitian conjugate) is recognized by tMMLT (or CMMLTC) and the computation is shortened accordingly.

Examples:

Assume that the two-dimensional arrays A, B, C, D, E, the one-dimensional array W, and the dummy variable V are declared by

    COMPLEX A(9,9),B(9,9),C(9,9),D(9,9),E(9,9),V,W(99)
and that a tex2html_wrap_inline287 matrix A, a tex2html_wrap_inline289 matrix B, and a tex2html_wrap_inline291 matrix C have been stored according to the Fortran conventions in arrays of corresponding name.
  1. To compute tex2html_wrap_inline293 :
        CALL CMMLT (4,5,7,A,A(1,2),A(2,1),B,B(1,2),B(2,1),D,D(1,2),D(2,1),V).
    To pack the tex2html_wrap_inline295 product matrix AB row-wise into array W:
        CALL CMMLT (4,5,7,A,A(1,2),A(2,1),B,B(2,1),B(1,2),W,W(2),W(8),V).
    (Note that tex2html_wrap_inline297 goes into W(1), tex2html_wrap_inline299 into W(2), and tex2html_wrap_inline301 into W(8)).

    For the purpose of abbreviation we shall denote
    A,A(1,2),A(2,1) by a, A,A(2,1),A(1,2) by a',
    and similarly for arrays B, C, D, E. The first example above then becomes

        CALL CMMLT(4,5,7,a,b,d,V).
  2. To compute tex2html_wrap_inline303 :
        CALL CMMLT(7,5,4,b',a',d,V)  or  CMMLT(4,5,7,a,b,d',V).
  3. To compute tex2html_wrap_inline305 and tex2html_wrap_inline307 :
        CALL CMMLT(4,5,4,a,a',d,V)
        CALL CMMLT(5,4,5,a',a,e,V).
  4. To replace A by AB or by tex2html_wrap_inline309 :
        CALL CMMLT(4,5,7,a,b,a,W)  or  CALL CMMLT(4,5,4,a,a',a,W).
    These two calls require a working vector W containing 7 or 4 complex elements, respectively.
  5. To compute tex2html_wrap_inline311 and tex2html_wrap_inline313 :
        CALL CMMLTC(4,5,7,a,b,d,V)
        CALL CMMLTC(3,7,5,c',b',e',V).
tex2html_wrap_inline315

Michel Goossens Wed Jun 5 04:20:51 METDST 1996