Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site h.cs.cmu.edu Path: utzoo!linus!philabs!cmcl2!seismo!rochester!pt.cs.cmu.edu!h.cs.cmu.edu!rfb From: rfb@h.cs.cmu.edu (Rick Busdiecker) Newsgroups: net.sources Subject: Re: matrix mult. (source and question) Message-ID: <266@h.cs.cmu.edu> Date: Sun, 17-Nov-85 10:59:38 EST Article-I.D.: h.266 Posted: Sun Nov 17 10:59:38 1985 Date-Received: Thu, 21-Nov-85 07:38:49 EST Organization: Carnegie-Mellon University, CS/RI Lines: 44 Subject: Re: matrix mult. (source and question) Message-Id: <501087498/rfb@H.CS.CMU.EDU> In-Reply-To: Gregory R. Simpson @ The North Coast's netnews message of Thu, 14-Nov-85 00:18:16 EST If Gregory Simpson's data representation were slightly different, things would go much more nicely, maybe even more nicely than in fortran 8-} Declaring a two-dimensional array is not equivalent to declaring an array of one-dimensional arrays, i.e. double matrix [m][n] is not the same as double (matrix [m]) [n]; however a reference to element (m,n) may still be coded as matrix[m][n] in a routine regardless of which declaration is used. With the second declaration element (m,n) could also be referenced as *(*(matrix + m) + n). /*=========================================================================== * matrix_multiply * * Multiplies the matrix a (dimension m,n) by the matrix b (dimension n,p) * into the matrix c (dimension m,p). Matrices must be declared explicitly * to be arrays of arrays rather than 2d arrays. */ void matrix_multiply (a, b, c, m, n, p) double **a, **b, **c; int m, n, p; { int i, j, k; for (i = 0; i < m; i++) for (j = 0; j < p; j++) { c [i][j] = 0.0; for (k = 1; k < n; k++) c += a [i][k] * b [k][j]; } }