Newsgroups: comp.lang.fortran Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!news.cs.indiana.edu!ariel.unm.edu!cie.uoregon.edu!scavo From: scavo@cie.uoregon.edu (Tom Scavo) Subject: matrix multiplication Reply-To: scavo@cie.uoregon.edu (Tom Scavo) Organization: Campus Information Exchange, University of Oregon Keywords: parameters, pass-by-value, pass-by-reference Message-ID: <1991May04.170203.22222@ariel.unm.edu> Date: Sat, 04 May 91 17:02:03 GMT Lines: 32 As you all know, a classic programming exercise is the matrix multiplication problem A = B C . mxn mxp pxn A robust algorithm will also handle the special case X = Y X (1) mxn mxm mxn where the result is to replace one of the matrices being multiplied. Such a calculation will break a naive algorithm, however. One solution is to pass B and C by *value* (with loss of efficiency in both time and space) but of course Fortran's insistence that all parameters be passed by reference precludes such an approach. On the other hand, pass-by-value can be simulated using a local array (for the lhs) declared within the matrix multiplication routine. Unfortunately, the dimensions of this local array put an operational limit on the size of the input matrices. I already have an inadequate routine that uses such a local array. How would I write a *general* matrix multiplication routine that handles tricky computations such as those in (1), and accomodates matrices of arbitrary size? Also, does anyone know of a Fortran compiler that implements pass-by-value-result, a kind of delayed pass-by-reference where the actual parameters are updated at the point of return? Or is this non-standard? Tom Scavo scavo@cie.uoregon.edu